[llvm] r246151 - [llvm-readobj] Add support for dumping MachO min version load command.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 08:11:33 PDT 2015
Author: davide
Date: Thu Aug 27 10:11:32 2015
New Revision: 246151
URL: http://llvm.org/viewvc/llvm-project?rev=246151&view=rev
Log:
[llvm-readobj] Add support for dumping MachO min version load command.
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
}
Differential Revision: http://reviews.llvm.org/D12373
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=246151&r1=246150&r2=246151&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Thu Aug 27 10:11:32 2015
@@ -42,6 +42,7 @@ public:
// MachO-specific.
void printMachODataInCode() override;
+ void printMachOVersionMin() override;
private:
template<class MachHeader>
@@ -625,3 +626,40 @@ void MachODumper::printMachODataInCode()
}
}
}
+
+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");
+ StringRef 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);
+ }
+ }
+}
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=246151&r1=246150&r2=246151&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Thu Aug 27 10:11:32 2015
@@ -56,6 +56,7 @@ public:
// Only implemented for MachO.
virtual void printMachODataInCode() { }
+ virtual void printMachOVersionMin() { }
virtual void printStackMap() const = 0;
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=246151&r1=246150&r2=246151&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Thu Aug 27 10:11:32 2015
@@ -186,6 +186,10 @@ namespace opts {
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 @@ static void dumpObject(const ObjectFile
if (Obj->isMachO())
if (opts::MachODataInCode)
Dumper->printMachODataInCode();
+ if (opts::MachOVersionMin)
+ Dumper->printMachOVersionMin();
if (opts::PrintStackMap)
Dumper->printStackMap();
}
More information about the llvm-commits
mailing list