[PATCH] D12373: [llvm-readobj] Add support for dumping macho min version load command
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 11:01:46 PDT 2015
davide created this revision.
davide added reviewers: grosbach, rafael, echristo.
davide added a subscriber: llvm-commits.
Herald added a subscriber: aemerson.
Example output:
File: <stdin>
Format: Mach-O arm
Arch: arm
AddressSize: 32bit
MinVersion {
Cmd: LC_VERSION_MIN_IPHONEOS
Size: 16
Version: 99.8.7
SDK: n/a
}
Meta-question: is this the granularity we want? llvm-objdump dumps this as part of -private-headers. Should I change that to match that behavior, or is it fine?
Tests will be added when this replaces macho-dump.
http://reviews.llvm.org/D12373
Files:
tools/llvm-readobj/MachODumper.cpp
tools/llvm-readobj/ObjDumper.h
tools/llvm-readobj/llvm-readobj.cpp
Index: tools/llvm-readobj/llvm-readobj.cpp
===================================================================
--- tools/llvm-readobj/llvm-readobj.cpp
+++ tools/llvm-readobj/llvm-readobj.cpp
@@ -186,6 +186,10 @@
MachODataInCode("macho-data-in-code",
cl::desc("Display MachO Data in Code command"));
+ // -macho-version-min
+ cl::opt<bool>
+ MachOVersionMin("macho-version-min",
+ cl::desc("Display MachO version min command"));
// -stackmap
cl::opt<bool>
PrintStackMap("stackmap",
@@ -320,6 +324,8 @@
if (Obj->isMachO())
if (opts::MachODataInCode)
Dumper->printMachODataInCode();
+ if (opts::MachOVersionMin)
+ Dumper->printMachOVersionMin();
if (opts::PrintStackMap)
Dumper->printStackMap();
}
Index: tools/llvm-readobj/ObjDumper.h
===================================================================
--- tools/llvm-readobj/ObjDumper.h
+++ tools/llvm-readobj/ObjDumper.h
@@ -56,6 +56,7 @@
// Only implemented for MachO.
virtual void printMachODataInCode() { }
+ virtual void printMachOVersionMin() { }
virtual void printStackMap() const = 0;
Index: tools/llvm-readobj/MachODumper.cpp
===================================================================
--- tools/llvm-readobj/MachODumper.cpp
+++ tools/llvm-readobj/MachODumper.cpp
@@ -42,6 +42,7 @@
// MachO-specific.
void printMachODataInCode() override;
+ void printMachOVersionMin() override;
private:
template<class MachHeader>
@@ -625,3 +626,40 @@
}
}
}
+
+void MachODumper::printMachOVersionMin() {
+ for (const auto &Load : Obj->load_commands()) {
+ if (Load.C.cmd == MachO::LC_VERSION_MIN_MACOSX ||
+ Load.C.cmd == MachO::LC_VERSION_MIN_IPHONEOS) {
+ MachO::version_min_command VMC = Obj->getVersionMinLoadCommand(Load);
+ DictScope Group(W, "MinVersion");
+ SmallString<32> Cmd;
+ if (Load.C.cmd == MachO::LC_VERSION_MIN_MACOSX)
+ Cmd = "LC_VERSION_MIN_MACOSX";
+ else
+ Cmd = "LC_VERSION_MIN_IPHONEOS";
+ W.printString("Cmd", Cmd);
+ W.printNumber("Size", VMC.cmdsize);
+ SmallString<32> Version;
+ Version = utostr(MachOObjectFile::getVersionMinMajor(VMC, false)) + "." +
+ utostr(MachOObjectFile::getVersionMinMinor(VMC, false));
+ uint32_t Update = MachOObjectFile::getVersionMinUpdate(VMC, false);
+ if (Update != 0)
+ Version += "." + utostr(MachOObjectFile::getVersionMinUpdate(VMC,
+ false));
+ W.printString("Version", Version);
+ SmallString<32> SDK;
+ if (VMC.sdk == 0)
+ SDK = "n/a";
+ else {
+ SDK = utostr(MachOObjectFile::getVersionMinMajor(VMC, true)) + "." +
+ utostr(MachOObjectFile::getVersionMinMinor(VMC, true));
+ uint32_t Update = MachOObjectFile::getVersionMinUpdate(VMC, true);
+ if (Update != 0)
+ SDK += "." + utostr(MachOObjectFile::getVersionMinUpdate(VMC,
+ true));
+ }
+ W.printString("SDK", SDK);
+ }
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12373.33224.patch
Type: text/x-patch
Size: 3131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150826/588f38c2/attachment.bin>
More information about the llvm-commits
mailing list