aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-09-21 22:16:43 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-09-21 22:16:43 +0000
commitafbaf48fc4a645a95737ea81e2e0fde47a6150ba (patch)
tree0b51ba473db693a69cfaafeec1975989e19640b3 /tools
parent3ca2ad11567f83883ae2719c5fac5afc30c7b3d1 (diff)
downloadexternal_llvm-afbaf48fc4a645a95737ea81e2e0fde47a6150ba.zip
external_llvm-afbaf48fc4a645a95737ea81e2e0fde47a6150ba.tar.gz
external_llvm-afbaf48fc4a645a95737ea81e2e0fde47a6150ba.tar.bz2
llvm-objdump: Detach symbol listing from section enumeration for mach-o.
This reduces memory usage as we don't add the same symbol multiple times anymore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-objdump/MachODump.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index 22eaab7..b474d5f 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -230,15 +230,6 @@ static void getSectionsAndSymbols(const macho::Header &Header,
MachOObj->ReadSection(LCI, SectNum, Sect);
Sections.push_back(copySection(Sect));
- // Store the symbols in this section.
- if (SymtabLC) {
- for (unsigned i = 0; i != (*SymtabLC)->NumSymbolTableEntries; ++i) {
- InMemoryStruct<macho::SymbolTableEntry> STE;
- MachOObj->ReadSymbolTableEntry((*SymtabLC)->SymbolTableOffset, i,
- STE);
- Symbols.push_back(copySymbol(STE));
- }
- }
}
} else if (LCI.Command.Type == macho::LCT_Segment64) {
InMemoryStruct<macho::Segment64LoadCommand> Segment64LC;
@@ -250,16 +241,6 @@ static void getSectionsAndSymbols(const macho::Header &Header,
InMemoryStruct<macho::Section64> Sect64;
MachOObj->ReadSection64(LCI, SectNum, Sect64);
Sections.push_back(copySection(Sect64));
-
- // Store the symbols in this section.
- if (SymtabLC) {
- for (unsigned i = 0; i != (*SymtabLC)->NumSymbolTableEntries; ++i) {
- InMemoryStruct<macho::Symbol64TableEntry> STE;
- MachOObj->ReadSymbol64TableEntry((*SymtabLC)->SymbolTableOffset, i,
- STE);
- Symbols.push_back(copySymbol(STE));
- }
- }
}
} else if (LCI.Command.Type == macho::LCT_FunctionStarts) {
// We found a function starts segment, parse the addresses for later
@@ -270,6 +251,22 @@ static void getSectionsAndSymbols(const macho::Header &Header,
MachOObj->ReadULEB128s(LLC->DataOffset, FoundFns);
}
}
+ // Store the symbols.
+ if (SymtabLC) {
+ for (unsigned i = 0; i != (*SymtabLC)->NumSymbolTableEntries; ++i) {
+ if (MachOObj->is64Bit()) {
+ InMemoryStruct<macho::Symbol64TableEntry> STE;
+ MachOObj->ReadSymbol64TableEntry((*SymtabLC)->SymbolTableOffset, i,
+ STE);
+ Symbols.push_back(copySymbol(STE));
+ } else {
+ InMemoryStruct<macho::SymbolTableEntry> STE;
+ MachOObj->ReadSymbolTableEntry((*SymtabLC)->SymbolTableOffset, i,
+ STE);
+ Symbols.push_back(copySymbol(STE));
+ }
+ }
+ }
}
void llvm::DisassembleInputMachO(StringRef Filename) {