tools: fix invalid printing, buffer overrun in llvm-readobj

All auxiliary records are consumed when accessing a File record.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool 2014-04-16 04:15:29 +00:00
parent eb0eb5dbec
commit 30e7a0ae04
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,21 @@
header: !Header
Machine: IMAGE_FILE_MACHINE_I386 # (0x14c)
Characteristics: [ IMAGE_FILE_DEBUG_STRIPPED ]
sections:
symbols:
- !Symbol
Name: .file
Value: 0
SectionNumber: 65534
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_FILE
File: first-section-has-eighteen-characters.asm
- !Symbol
Name: '@comp.id'
Value: 13485607
SectionNumber: 65535
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_STATIC

View File

@ -0,0 +1,18 @@
RUN: yaml2obj %p/Inputs/file-multiple-aux-records.yaml | llvm-readobj -t - | FileCheck %s
CHECK: Symbols [
CHECK: Symbol {
CHECK: Name: .file
CHECK: Value: 0
CHECK: Section: (65534)
CHECK: BaseType: Null (0x0)
CHECK: ComplexType: Null (0x0)
CHECK: StorageClass: File (0x67)
CHECK: AuxSymbolCount: 3
CHECK: AuxFileRecord {
CHECK: FileName: first-section-has-eighteen-characters.asm
CHECK: }
CHECK-NOT: AuxFileRecord {
CHECK: }
CHECK: ]

View File

@ -981,6 +981,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
StringRef Name(Aux->FileName,
Symbol->NumberOfAuxSymbols * COFF::SymbolSize);
W.printString("FileName", Name.rtrim(StringRef("\0", 1)));
break;
} else if (Symbol->isSectionDefinition()) {
const coff_aux_section_definition *Aux;
if (error(getSymbolAuxData(Obj, Symbol + I, Aux)))