Skip to content

Commit

Permalink
tools: fix invalid printing, buffer overrun in llvm-readobj
Browse files Browse the repository at this point in the history
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
  • Loading branch information
compnerd committed Apr 16, 2014
1 parent eb0eb5d commit 30e7a0a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/tools/llvm-readobj/Inputs/file-multiple-aux-records.yaml
Original file line number Diff line number Diff line change
@@ -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

18 changes: 18 additions & 0 deletions test/tools/llvm-readobj/coff-file-sections-reading.test
Original file line number Diff line number Diff line change
@@ -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: ]

1 change: 1 addition & 0 deletions tools/llvm-readobj/COFFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 30e7a0a

Please sign in to comment.