[llvm] r252867 - [Object, MachO] Mark symbols from DATA and BSS sections as ST_Data
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 01:40:29 PST 2015
Author: kuba.brecka
Date: Thu Nov 12 03:40:29 2015
New Revision: 252867
URL: http://llvm.org/viewvc/llvm-project?rev=252867&view=rev
Log:
[Object, MachO] Mark symbols from DATA and BSS sections as ST_Data
In `MachOObjectFile::getSymbolType` we currently always return `SymbolRef::ST_Function` for symbols from any section. In order for llvm-symbolizer to correctly symbolize Mach-O globals, symbols from data and BSS sections should return `SymbolRef::ST_Data`.
Differential Revision: http://reviews.llvm.org/D14576
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/test/tools/llvm-objdump/X86/macho-symbol-table.test
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=252867&r1=252866&r2=252867&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Nov 12 03:40:29 2015
@@ -401,6 +401,9 @@ SymbolRef::Type MachOObjectFile::getSymb
case MachO::N_UNDF :
return SymbolRef::ST_Unknown;
case MachO::N_SECT :
+ section_iterator Sec = *getSymbolSection(Symb);
+ if (Sec->isData() || Sec->isBSS())
+ return SymbolRef::ST_Data;
return SymbolRef::ST_Function;
}
return SymbolRef::ST_Other;
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=252867&r1=252866&r2=252867&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 Thu Nov 12 03:40:29 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 L_.str
-CHECK: 0000000000000068 l F __TEXT,__eh_frame EH_frame0
+CHECK: 000000000000003b l __TEXT,__cstring L_.str
+CHECK: 0000000000000068 l __TEXT,__eh_frame EH_frame0
CHECK: 0000000000000000 g F __TEXT,__text _main
-CHECK: 0000000000000080 g F __TEXT,__eh_frame _main.eh
+CHECK: 0000000000000080 g __TEXT,__eh_frame _main.eh
CHECK: 0000000000000000 *UND* _printf
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=252867&r1=252866&r2=252867&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Thu Nov 12 03:40:29 2015
@@ -6173,7 +6173,7 @@ static void DisassembleMachO(StringRef F
StringRef SymName = *SymNameOrErr;
SymbolRef::Type ST = Symbols[SymIdx].getType();
- if (ST != SymbolRef::ST_Function)
+ if (ST != SymbolRef::ST_Function && ST != SymbolRef::ST_Data)
continue;
// Make sure the symbol is defined in this section.
More information about the llvm-commits
mailing list