diff options
author | Kevin Enderby <enderby@apple.com> | 2015-04-16 22:33:20 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2015-04-16 22:33:20 +0000 |
commit | 4ad9bded46fc4a0209dd4e64e19aed0d672d792a (patch) | |
tree | 4aae8722a4bc78da16cd0dbbede42968a7fb62e7 /llvm/tools/llvm-objdump | |
parent | 7bb480dbc274c74fb2ede464e3a1849c18fbfc8c (diff) | |
download | bcm5719-llvm-4ad9bded46fc4a0209dd4e64e19aed0d672d792a.tar.gz bcm5719-llvm-4ad9bded46fc4a0209dd4e64e19aed0d672d792a.zip |
For llvm-objdump, dump the (__OBJC,__protocol) section for Objc1 32-bit Mach-O files
with the -section option as objc_protocol_t structs.
llvm-svn: 235141
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 281ce9cc1f2..a491a376861 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1025,6 +1025,8 @@ static void DumpRawSectionContents(MachOObjectFile *O, const char *sect, static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, StringRef DisSegName, StringRef DisSectName); +static void DumpProtocolSection(MachOObjectFile *O, const char *sect, + uint32_t size, uint32_t addr); static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, bool verbose) { @@ -1087,6 +1089,10 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, outs() << sect; continue; } + if (SegName == "__OBJC" && SectName == "__protocol") { + DumpProtocolSection(O, sect, sect_size, sect_addr); + continue; + } switch (section_type) { case MachO::S_REGULAR: DumpRawSectionContents(O, sect, sect_size, sect_addr); @@ -5545,6 +5551,52 @@ static bool printObjc1_32bit_MetaData(MachOObjectFile *O, bool verbose) { return true; } +static void DumpProtocolSection(MachOObjectFile *O, const char *sect, + uint32_t size, uint32_t addr) { + SymbolAddressMap AddrMap; + CreateSymbolAddressMap(O, &AddrMap); + + std::vector<SectionRef> Sections; + for (const SectionRef &Section : O->sections()) { + StringRef SectName; + Section.getName(SectName); + Sections.push_back(Section); + } + + struct DisassembleInfo info; + // Set up the block of info used by the Symbolizer call backs. + info.verbose = true; + info.O = O; + info.AddrMap = &AddrMap; + info.Sections = &Sections; + info.class_name = nullptr; + info.selector_name = nullptr; + info.method = nullptr; + info.demangled_name = nullptr; + info.bindtable = nullptr; + info.adrp_addr = 0; + info.adrp_inst = 0; + + const char *p; + struct objc_protocol_t protocol; + uint32_t left, paddr; + for (p = sect; p < sect + size; p += sizeof(struct objc_protocol_t)) { + memset(&protocol, '\0', sizeof(struct objc_protocol_t)); + left = size - (p - sect); + if (left < sizeof(struct objc_protocol_t)) { + outs() << "Protocol extends past end of __protocol section\n"; + memcpy(&protocol, p, left); + } else + memcpy(&protocol, p, sizeof(struct objc_protocol_t)); + if (O->isLittleEndian() != sys::IsLittleEndianHost) + swapStruct(protocol); + paddr = addr + (p - sect); + outs() << "Protocol " << format("0x%" PRIx32, paddr); + if (print_protocol(paddr, 0, &info)) + outs() << "(not in an __OBJC section)\n"; + } +} + static void printObjcMetaData(MachOObjectFile *O, bool verbose) { if (O->is64Bit()) printObjc2_64bit_MetaData(O, verbose); |