This is https://bugs.llvm.org/show_bug.cgi?id=26892,
GNU objdump hides the special symbol entry:
SYMBOL TABLE:
000000000000a7e0 l F .text
00000000000003f9 bi_copymodules
while llvm-objdump does not:
SYMBOL TABLE:
0000000000000000 *UND*
00000000
000000000000a7e0 l F .text
000003f9 bi_copymodules
Patch makes the behavior of the llvm-objdump to be consistent with the GNU objdump.
Differential revision: https://reviews.llvm.org/D56076
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350840
91177308-0d34-0410-b5e6-
96231b3b80d8
## Check we demangle symbols when printing symbol table.
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000000000 g F .text 00000000 foo()
## Check the case when relocations are inlined into disassembly.
CHECK-NEXT: _start:
CHECK-NEXT: 10: c3 retl
CHECK-NEXT: SYMBOL TABLE:
-CHECK-NEXT: 00000000 *UND* 00000000
CHECK-NEXT: 00000010 l d .text 00000000 .text
CHECK-NEXT: 00000010 .text 00000000 _start
CHECK-NEXT: 00000020 .text 00000000 _fdata
# RUN: FileCheck %s --input-file=%t1
# CHECK: SYMBOL TABLE:
-# CHECK-NEXT: 0000000000000000 *UND* 00000000
# CHECK-NEXT: 0000000000001004 l F .text 00000000 lfoo
# CHECK-NEXT: 0000000000001008 l O .text 00000000 lbar
# CHECK-NEXT: 0000000000001004 g F .text 00000000 foo
printCOFFSymbolTable(coff);
return;
}
- for (const SymbolRef &Symbol : o->symbols()) {
+
+ for (auto I = o->symbol_begin(), E = o->symbol_end(); I != E; ++I) {
+ // Skip printing the special zero symbol when dumping an ELF file.
+ // This makes the output consistent with the GNU objdump.
+ if (I == o->symbol_begin() && isa<ELFObjectFileBase>(o))
+ continue;
+
+ const SymbolRef &Symbol = *I;
Expected<uint64_t> AddressOrError = Symbol.getAddress();
if (!AddressOrError)
report_error(ArchiveName, o->getFileName(), AddressOrError.takeError(),