From f879f14cef93fe51ee8c180be7acf70294807b8f Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 27 Nov 2010 08:33:44 +0000 Subject: macho-dump: Add support for dumping symtab and dysymtab commands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120204 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/macho-dump/macho-dump.cpp | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tools/macho-dump') diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp index 34a9527..9648cae 100644 --- a/tools/macho-dump/macho-dump.cpp +++ b/tools/macho-dump/macho-dump.cpp @@ -111,6 +111,52 @@ static int DumpSegment64Command(MachOObject &Obj, return 0; } +static int DumpSymtabCommand(MachOObject &Obj, + const MachOObject::LoadCommandInfo &LCI) { + InMemoryStruct SLC; + Obj.ReadSymtabLoadCommand(LCI, SLC); + if (!SLC) + return Error("unable to read segment load command"); + + outs() << " ('symoff', " << SLC->SymbolTableOffset << ")\n"; + outs() << " ('nsyms', " << SLC->NumSymbolTableEntries << ")\n"; + outs() << " ('stroff', " << SLC->StringTableOffset << ")\n"; + outs() << " ('strsize', " << SLC->StringTableSize << ")\n"; + + return 0; +} + +static int DumpDysymtabCommand(MachOObject &Obj, + const MachOObject::LoadCommandInfo &LCI) { + InMemoryStruct DLC; + Obj.ReadDysymtabLoadCommand(LCI, DLC); + if (!DLC) + return Error("unable to read segment load command"); + + outs() << " ('ilocalsym', " << DLC->LocalSymbolIndex << ")\n"; + outs() << " ('nlocalsym', " << DLC->NumLocalSymbols << ")\n"; + outs() << " ('iextdefsym', " << DLC->ExternalSymbolsIndex << ")\n"; + outs() << " ('nextdefsym', " << DLC->NumExternalSymbols << ")\n"; + outs() << " ('iundefsym', " << DLC->UndefinedSymbolsIndex << ")\n"; + outs() << " ('nundefsym', " << DLC->NumUndefinedSymbols << ")\n"; + outs() << " ('tocoff', " << DLC->TOCOffset << ")\n"; + outs() << " ('ntoc', " << DLC->NumTOCEntries << ")\n"; + outs() << " ('modtaboff', " << DLC->ModuleTableOffset << ")\n"; + outs() << " ('nmodtab', " << DLC->NumModuleTableEntries << ")\n"; + outs() << " ('extrefsymoff', " << DLC->ReferenceSymbolTableOffset << ")\n"; + outs() << " ('nextrefsyms', " + << DLC->NumReferencedSymbolTableEntries << ")\n"; + outs() << " ('indirectsymoff', " << DLC->IndirectSymbolTableOffset << ")\n"; + outs() << " ('nindirectsyms', " + << DLC->NumIndirectSymbolTableEntries << ")\n"; + outs() << " ('extreloff', " << DLC->ExternalRelocationTableOffset << ")\n"; + outs() << " ('nextrel', " << DLC->NumExternalRelocationTableEntries << ")\n"; + outs() << " ('locreloff', " << DLC->LocalRelocationTableOffset << ")\n"; + outs() << " ('nlocrel', " << DLC->NumLocalRelocationTableEntries << ")\n"; + + return 0; +} + static int DumpLoadCommand(MachOObject &Obj, unsigned Index) { const MachOObject::LoadCommandInfo &LCI = Obj.getLoadCommandInfo(Index); int Res = 0; @@ -125,6 +171,12 @@ static int DumpLoadCommand(MachOObject &Obj, unsigned Index) { case macho::LCT_Segment64: Res = DumpSegment64Command(Obj, LCI); break; + case macho::LCT_Symtab: + Res = DumpSymtabCommand(Obj, LCI); + break; + case macho::LCT_Dysymtab: + Res = DumpDysymtabCommand(Obj, LCI); + break; default: Warning("unknown load command: " + Twine(LCI.Command.Type)); break; -- cgit v1.1