diff options
author | Kevin Enderby <enderby@apple.com> | 2015-02-04 21:38:42 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2015-02-04 21:38:42 +0000 |
commit | 10ba0411887d4fcc497cc383a31acd92a0bed46f (patch) | |
tree | b8145a61514f817339c6b97c89fbca1b4dcc5369 /llvm/tools/llvm-objdump/MachODump.cpp | |
parent | a092f17580d76749a4f96714d6fe6fb26d1a174a (diff) | |
download | bcm5719-llvm-10ba0411887d4fcc497cc383a31acd92a0bed46f.tar.gz bcm5719-llvm-10ba0411887d4fcc497cc383a31acd92a0bed46f.zip |
Add code to llvm-objdump so the -section option with -macho will dump āCā string
sections with the Mach-O S_CSTRING_LITERALS section type.
llvm-svn: 228198
Diffstat (limited to 'llvm/tools/llvm-objdump/MachODump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 9a0255d428b..1bb9bfce666 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -537,6 +537,25 @@ static const char *GuessSymbolName(uint64_t value, SymbolAddressMap *AddrMap) { return SymbolName; } +static void DumpCstringSection(MachOObjectFile *O, const char *sect, + uint32_t sect_size, uint64_t sect_addr, + bool verbose) { + for (uint32_t i = 0; i < sect_size; i++) { + if (O->is64Bit()) + outs() << format("0x%016" PRIx64, sect_addr + i) << " "; + else + outs() << format("0x%08" PRIx64, sect_addr + i) << " "; + for ( ; i < sect_size && sect[i] != '\0'; i++) { + char p[2]; + p[0] = sect[i]; + p[1] = '\0'; + outs().write_escaped(p); + } + if (i < sect_size && sect[i] == '\0') + outs() << "\n"; + } +} + static void DumpInitTermPointerSection(MachOObjectFile *O, const char *sect, uint32_t sect_size, uint64_t sect_addr, SymbolAddressMap *AddrMap, @@ -676,6 +695,9 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, case MachO::S_ZEROFILL: outs() << "zerofill section and has no contents in the file\n"; break; + case MachO::S_CSTRING_LITERALS: + DumpCstringSection(O, sect, sect_size, sect_addr, verbose); + break; case MachO::S_MOD_INIT_FUNC_POINTERS: case MachO::S_MOD_TERM_FUNC_POINTERS: DumpInitTermPointerSection(O, sect, sect_size, sect_addr, &AddrMap, |