[llvm] r245732 - [llvm-readobj] Add support for MachO DataInCodeDataCommand.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 13:28:30 PDT 2015
Author: davide
Date: Fri Aug 21 15:28:30 2015
New Revision: 245732
URL: http://llvm.org/viewvc/llvm-project?rev=245732&view=rev
Log:
[llvm-readobj] Add support for MachO DataInCodeDataCommand.
Example output:
File: <stdin>
Format: Mach-O arm
Arch: arm
AddressSize: 32bit
DataInCode {
Data offset: 300
Data size: 32
Data Regions [
DICE {
Index: 0
Offset: 0
Length: 4
Kind: 1
}
DICE {
Index: 1
Offset: 4
Length: 4
Kind: 4
}
DICE {
Index: 2
Offset: 8
Length: 2
Kind: 3
}
DICE {
Index: 3
Offset: 10
Length: 1
Kind: 2
}
]
}
Differential Revision: http://reviews.llvm.org/D12084
Modified:
llvm/trunk/tools/llvm-readobj/MachODumper.cpp
llvm/trunk/tools/llvm-readobj/ObjDumper.h
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=245732&r1=245731&r2=245732&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Fri Aug 21 15:28:30 2015
@@ -40,6 +40,9 @@ public:
void printUnwindInfo() override;
void printStackMap() const override;
+ // MachO-specific.
+ void printMachODataInCode() override;
+
private:
template<class MachHeader>
void printFileHeaders(const MachHeader &Header);
@@ -600,3 +603,25 @@ void MachODumper::printStackMap() const
prettyPrintStackMap(llvm::outs(),
StackMapV1Parser<support::big>(StackMapContentsArray));
}
+
+void MachODumper::printMachODataInCode() {
+ for (const auto &Load : Obj->load_commands()) {
+ if (Load.C.cmd == MachO::LC_DATA_IN_CODE) {
+ MachO::linkedit_data_command LLC = Obj->getLinkeditDataLoadCommand(Load);
+ DictScope Group(W, "DataInCode");
+ W.printNumber("Data offset", LLC.dataoff);
+ W.printNumber("Data size", LLC.datasize);
+ ListScope D(W, "Data entries");
+ unsigned NumRegions = LLC.datasize / sizeof(MachO::data_in_code_entry);
+ for (unsigned i = 0; i < NumRegions; ++i) {
+ MachO::data_in_code_entry DICE = Obj->getDataInCodeTableEntry(
+ LLC.dataoff, i);
+ DictScope Group(W, "Entry");
+ W.printNumber("Index", i);
+ W.printNumber("Offset", DICE.offset);
+ W.printNumber("Length", DICE.length);
+ W.printNumber("Kind", DICE.kind);
+ }
+ }
+ }
+}
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=245732&r1=245731&r2=245732&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Fri Aug 21 15:28:30 2015
@@ -54,6 +54,9 @@ public:
virtual void printCOFFDirectives() { }
virtual void printCOFFBaseReloc() { }
+ // Only implemented for MachO.
+ virtual void printMachODataInCode() { }
+
virtual void printStackMap() const = 0;
protected:
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=245732&r1=245731&r2=245732&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Fri Aug 21 15:28:30 2015
@@ -181,6 +181,11 @@ namespace opts {
COFFBaseRelocs("coff-basereloc",
cl::desc("Display the PE/COFF .reloc section"));
+ // -macho-data-in-code
+ cl::opt<bool>
+ MachODataInCode("macho-data-in-code",
+ cl::desc("Display MachO Data in Code command"));
+
// -stackmap
cl::opt<bool>
PrintStackMap("stackmap",
@@ -312,6 +317,9 @@ static void dumpObject(const ObjectFile
if (opts::COFFBaseRelocs)
Dumper->printCOFFBaseReloc();
}
+ if (Obj->isMachO())
+ if (opts::MachODataInCode)
+ Dumper->printMachODataInCode();
if (opts::PrintStackMap)
Dumper->printStackMap();
}
More information about the llvm-commits
mailing list