diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-03-27 17:31:15 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-03-27 17:31:15 +0000 |
commit | c2401ddf84d0266e289f79a874c2960415ef4d5b (patch) | |
tree | 448ddab23fd1a9f42825a5414d7b2585c43d14c9 /llvm/tools/llvm-objdump | |
parent | 3d2afaa29ea78b6170da9852ce5d57480720d1e0 (diff) | |
download | bcm5719-llvm-c2401ddf84d0266e289f79a874c2960415ef4d5b.tar.gz bcm5719-llvm-c2401ddf84d0266e289f79a874c2960415ef4d5b.zip |
Add a -raw option to the -section mode of llvm-objdump.
llvm-svn: 233390
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 16 | ||||
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.h | 1 |
2 files changed, 14 insertions, 3 deletions
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 86504e60a2d..fc72bc383b6 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -99,6 +99,9 @@ cl::list<std::string> cl::desc("Prints the specified segment,section for " "Mach-O objects (requires -macho)")); +cl::opt<bool> llvm::Raw("raw", + cl::desc("Have -section dump the raw binary contents")); + cl::opt<bool> llvm::InfoPlist("info-plist", cl::desc("Print the info plist section as strings for " @@ -1043,8 +1046,7 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, StringRef SegName = O->getSectionFinalSegmentName(Ref); if ((DumpSegName.empty() || SegName == DumpSegName) && (SectName == DumpSectName)) { - outs() << "Contents of (" << SegName << "," << SectName - << ") section\n"; + uint32_t section_flags; if (O->is64Bit()) { const MachO::section_64 Sec = O->getSection64(Ref); @@ -1062,6 +1064,14 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, uint32_t sect_size = BytesStr.size(); uint64_t sect_addr = Section.getAddress(); + if (Raw) { + outs().write(BytesStr.data(), BytesStr.size()); + continue; + } + + outs() << "Contents of (" << SegName << "," << SectName + << ") section\n"; + if (verbose) { if ((section_flags & MachO::S_ATTR_PURE_INSTRUCTIONS) || (section_flags & MachO::S_ATTR_SOME_INSTRUCTIONS)) { @@ -1181,7 +1191,7 @@ static void ProcessMachO(StringRef Filename, MachOObjectFile *MachOOF, // UniversalHeaders or ArchiveHeaders. if (Disassemble || PrivateHeaders || ExportsTrie || Rebase || Bind || LazyBind || WeakBind || IndirectSymbols || DataInCode || LinkOptHints || - DylibsUsed || DylibId || DumpSections.size() != 0) { + DylibsUsed || DylibId || (DumpSections.size() != 0 && !Raw)) { outs() << Filename; if (!ArchiveMemberName.empty()) outs() << '(' << ArchiveMemberName << ')'; diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h index c1d5ff8c211..5d0099b18b0 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.h +++ b/llvm/tools/llvm-objdump/llvm-objdump.h @@ -27,6 +27,7 @@ extern cl::opt<std::string> ArchName; extern cl::opt<std::string> MCPU; extern cl::list<std::string> MAttrs; extern cl::list<std::string> DumpSections; +extern cl::opt<bool> Raw; extern cl::opt<bool> Disassemble; extern cl::opt<bool> NoShowRawInsn; extern cl::opt<bool> PrivateHeaders; |