[llvm] r233390 - Add a -raw option to the -section mode of llvm-objdump.
Adrian Prantl
aprantl at apple.com
Fri Mar 27 10:31:15 PDT 2015
Author: adrian
Date: Fri Mar 27 12:31:15 2015
New Revision: 233390
URL: http://llvm.org/viewvc/llvm-project?rev=233390&view=rev
Log:
Add a -raw option to the -section mode of llvm-objdump.
Added:
llvm/trunk/test/tools/llvm-objdump/macho-sections.test
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.h
Added: llvm/trunk/test/tools/llvm-objdump/macho-sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/macho-sections.test?rev=233390&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/macho-sections.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/macho-sections.test Fri Mar 27 12:31:15 2015
@@ -0,0 +1,5 @@
+# RUN: llvm-objdump -macho -section=__data %p/Inputs/bind2.macho-x86_64 | FileCheck %s
+# RUN: llvm-objdump -macho -section=__data -raw %p/Inputs/bind2.macho-x86_64 | FileCheck --check-prefix=RAW %s
+
+# CHECK: bind2.macho-x86_64:
+# RAW-NOT: bind2.macho-x86_64:
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=233390&r1=233389&r2=233390&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Fri Mar 27 12:31:15 2015
@@ -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(StringRe
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(StringRe
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 Filen
// 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 << ')';
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.h?rev=233390&r1=233389&r2=233390&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.h (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.h Fri Mar 27 12:31:15 2015
@@ -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;
More information about the llvm-commits
mailing list