[llvm] r240422 - objdump: Don't print a (always 0) size for MachO symbols.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jun 23 08:45:38 PDT 2015
Author: rafael
Date: Tue Jun 23 10:45:38 2015
New Revision: 240422
URL: http://llvm.org/viewvc/llvm-project?rev=240422&view=rev
Log:
objdump: Don't print a (always 0) size for MachO symbols.
Only common symbol on MachO and COFF have a size.
For COFF we already had a custom format.
For MachO, there is no native objdump and we were printing it as ELF. Now
we only print the sizes for symbols that actually have them.
Modified:
llvm/trunk/test/Object/objdump-symbol-table.test
llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/test/Object/objdump-symbol-table.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/objdump-symbol-table.test?rev=240422&r1=240421&r2=240422&view=diff
==============================================================================
--- llvm/trunk/test/Object/objdump-symbol-table.test (original)
+++ llvm/trunk/test/Object/objdump-symbol-table.test Tue Jun 23 10:45:38 2015
@@ -30,9 +30,9 @@ ELF-i386: 00000000 *UND* 000000
macho-i386: trivial-object-test.macho-i386: file format Mach-O 32-bit i386
macho-i386: SYMBOL TABLE:
-macho-i386: 00000000 g F __TEXT,__text 00000000 _main
-macho-i386: 00000000 *UND* 00000000 _SomeOtherFunction
-macho-i386: 00000000 *UND* 00000000 _puts
+macho-i386: 00000000 g F __TEXT,__text _main
+macho-i386: 00000000 *UND* _SomeOtherFunction
+macho-i386: 00000000 *UND* _puts
ELF-shared: shared-object-test.elf-i386: file format
ELF-shared: SYMBOL TABLE:
Modified: llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test?rev=240422&r1=240421&r2=240422&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test Tue Jun 23 10:45:38 2015
@@ -1,8 +1,8 @@
RUN: llvm-objdump -macho -t %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
CHECK: SYMBOL TABLE:
-CHECK: 000000000000003b l F __TEXT,__cstring 00000000 L_.str
-CHECK: 0000000000000068 l F __TEXT,__eh_frame 00000000 EH_frame0
-CHECK: 0000000000000000 g F __TEXT,__text 00000000 _main
-CHECK: 0000000000000080 g F __TEXT,__eh_frame 00000000 _main.eh
-CHECK: 0000000000000000 *UND* 00000000 _printf
+CHECK: 000000000000003b l F __TEXT,__cstring L_.str
+CHECK: 0000000000000068 l F __TEXT,__eh_frame EH_frame0
+CHECK: 0000000000000000 g F __TEXT,__text _main
+CHECK: 0000000000000080 g F __TEXT,__eh_frame _main.eh
+CHECK: 0000000000000000 *UND* _printf
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=240422&r1=240421&r2=240422&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Jun 23 10:45:38 2015
@@ -1085,7 +1085,6 @@ void llvm::PrintSymbolTable(const Object
continue;
if (error(Symbol.getType(Type)))
continue;
- uint64_t Size = Symbol.getSize();
if (error(Symbol.getSection(Section)))
continue;
StringRef Name;
@@ -1101,15 +1100,11 @@ void llvm::PrintSymbolTable(const Object
bool Common = Flags & SymbolRef::SF_Common;
bool Hidden = Flags & SymbolRef::SF_Hidden;
- if (Common) {
- uint32_t Alignment = Symbol.getAlignment();
- Address = Size;
- Size = Alignment;
- }
+ if (Common)
+ Address = Symbol.getSize();
+
if (Address == UnknownAddressOrSize)
Address = 0;
- if (Size == UnknownAddressOrSize)
- Size = 0;
char GlobLoc = ' ';
if (Type != SymbolRef::ST_Unknown)
GlobLoc = Global ? 'g' : 'l';
@@ -1151,8 +1146,13 @@ void llvm::PrintSymbolTable(const Object
SectionName = "";
outs() << SectionName;
}
- outs() << '\t'
- << format("%08" PRIx64 " ", Size);
+
+ outs() << '\t';
+ if (Common)
+ outs() << format("%08" PRIx64 " ", Symbol.getAlignment());
+ else if (isa<ELFObjectFileBase>(o))
+ outs() << format("%08" PRIx64 " ", Symbol.getSize());
+
if (Hidden) {
outs() << ".hidden ";
}
More information about the llvm-commits
mailing list