]> granicus.if.org Git - llvm/commitdiff
[llvm-objdump] - Do not include reserved undefined symbol in -t output.
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 10 Jan 2019 16:24:10 +0000 (16:24 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 10 Jan 2019 16:24:10 +0000 (16:24 +0000)
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

test/tools/llvm-objdump/X86/demangle.s
test/tools/llvm-objdump/X86/out-of-section-sym.test
test/tools/llvm-objdump/symbol-table-elf.test
tools/llvm-objdump/llvm-objdump.cpp

index d7c7bfb4596d4e07ab62122a66623a4a5d1c4791..e20fa3de5c2c48799c97603cfca342609dc387eb 100644 (file)
@@ -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.
index f70dce6a8ed81e46e520680e3b97c08d7ebdf6d7..55de107a60b31757889fa2adf157569f0e0e613f 100644 (file)
@@ -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
index abe339d7d536bd3fd7c3951003af297c26aa93fc..649e54c99bf85a3f40172fcc8a8d67c3cae10274 100644 (file)
@@ -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
index 21359a702c67083d2851f804cc82ee63edc60ff9..b68714e624a5711ca4dfc0acb72803adf32e4ae3 100644 (file)
@@ -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<ELFObjectFileBase>(o))
+      continue;
+
+    const SymbolRef &Symbol = *I;
     Expected<uint64_t> AddressOrError = Symbol.getAddress();
     if (!AddressOrError)
       report_error(ArchiveName, o->getFileName(), AddressOrError.takeError(),