From d51855e21de17888abebd5ab850006593bb3e156 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 25 May 2016 01:59:32 +0000 Subject: [PATCH] llvm-objdump: support dumping AUX records for weak externals This is a support COFF feature. Ensure that we can display the weak externals auxiliary symbol. It contains useful information (such as the default binding and how to resolve the symbol). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270648 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/Inputs/COFF/weak-externals.yaml | 26 +++++++++++++++++++++ test/Object/coff-weak-externals.test | 5 ++++ tools/llvm-objdump/COFFDump.cpp | 6 +++++ 3 files changed, 37 insertions(+) create mode 100644 test/Object/Inputs/COFF/weak-externals.yaml create mode 100644 test/Object/coff-weak-externals.test diff --git a/test/Object/Inputs/COFF/weak-externals.yaml b/test/Object/Inputs/COFF/weak-externals.yaml new file mode 100644 index 00000000000..44364186b52 --- /dev/null +++ b/test/Object/Inputs/COFF/weak-externals.yaml @@ -0,0 +1,26 @@ +--- +header: + Machine: IMAGE_FILE_MACHINE_ARMNT + Characteristics: [ ] +sections: + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 1 + SectionData: '' +symbols: + - Name: Function + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_WEAK_EXTERNAL + WeakExternal: + TagIndex: 9 + Characteristics: IMAGE_WEAK_EXTERN_SEARCH_LIBRARY + - Name: .weak.Function.default + Value: 0 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/Object/coff-weak-externals.test b/test/Object/coff-weak-externals.test new file mode 100644 index 00000000000..b7a0980ff72 --- /dev/null +++ b/test/Object/coff-weak-externals.test @@ -0,0 +1,5 @@ +RUN: yaml2obj %p/Inputs/COFF/weak-externals.yaml | llvm-objdump -t - | FileCheck %s + +CHECK: [ 0](sec 0)(fl 0x00)(ty 0)(scl 69) (nx 1) 0x00000000 Function +CHECK: AUX tagndx 9 type 2 + diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index 6b98b72b5c1..3b72f9bcad7 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/tools/llvm-objdump/COFFDump.cpp @@ -653,6 +653,12 @@ void llvm::printCOFFSymbolTable(const COFFObjectFile *coff) { SI = SI + Symbol->getNumberOfAuxSymbols(); break; + } else if (Symbol->isWeakExternal()) { + const coff_aux_weak_external *awe; + error(coff->getAuxSymbol(SI + 1, awe)); + + outs() << "AUX " << format("tagndx %d type %d\n", awe->TagIndex, + awe->Characteristics); } else { outs() << "AUX Unknown\n"; }