From: George Rimar Date: Thu, 10 Jan 2019 16:24:10 +0000 (+0000) Subject: [llvm-objdump] - Do not include reserved undefined symbol in -t output. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03e297e48e3b40e4530381e967da6b32c9667b62;p=llvm [llvm-objdump] - Do not include reserved undefined symbol in -t output. 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 --- diff --git a/test/tools/llvm-objdump/X86/demangle.s b/test/tools/llvm-objdump/X86/demangle.s index d7c7bfb4596..e20fa3de5c2 100644 --- a/test/tools/llvm-objdump/X86/demangle.s +++ b/test/tools/llvm-objdump/X86/demangle.s @@ -6,7 +6,6 @@ ## 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. diff --git a/test/tools/llvm-objdump/X86/out-of-section-sym.test b/test/tools/llvm-objdump/X86/out-of-section-sym.test index f70dce6a8ed..55de107a60b 100644 --- a/test/tools/llvm-objdump/X86/out-of-section-sym.test +++ b/test/tools/llvm-objdump/X86/out-of-section-sym.test @@ -6,7 +6,6 @@ CHECK: Disassembly of section .text: 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 diff --git a/test/tools/llvm-objdump/symbol-table-elf.test b/test/tools/llvm-objdump/symbol-table-elf.test index abe339d7d53..649e54c99bf 100644 --- a/test/tools/llvm-objdump/symbol-table-elf.test +++ b/test/tools/llvm-objdump/symbol-table-elf.test @@ -5,7 +5,6 @@ # 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 diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 21359a702c6..b68714e624a 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -2015,7 +2015,14 @@ void llvm::PrintSymbolTable(const ObjectFile *o, StringRef ArchiveName, 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(o)) + continue; + + const SymbolRef &Symbol = *I; Expected AddressOrError = Symbol.getAddress(); if (!AddressOrError) report_error(ArchiveName, o->getFileName(), AddressOrError.takeError(),