llvm.org GIT mirror llvm / 7dbe74f
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246151 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 5 years ago
3 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4141
4242 // MachO-specific.
4343 void printMachODataInCode() override;
44 void printMachOVersionMin() override;
4445
4546 private:
4647 template
624625 }
625626 }
626627 }
628
629 void MachODumper::printMachOVersionMin() {
630 for (const auto &Load : Obj->load_commands()) {
631 if (Load.C.cmd == MachO::LC_VERSION_MIN_MACOSX ||
632 Load.C.cmd == MachO::LC_VERSION_MIN_IPHONEOS) {
633 MachO::version_min_command VMC = Obj->getVersionMinLoadCommand(Load);
634 DictScope Group(W, "MinVersion");
635 StringRef Cmd;
636 if (Load.C.cmd == MachO::LC_VERSION_MIN_MACOSX)
637 Cmd = "LC_VERSION_MIN_MACOSX";
638 else
639 Cmd = "LC_VERSION_MIN_IPHONEOS";
640 W.printString("Cmd", Cmd);
641 W.printNumber("Size", VMC.cmdsize);
642 SmallString<32> Version;
643 Version = utostr(MachOObjectFile::getVersionMinMajor(VMC, false)) + "." +
644 utostr(MachOObjectFile::getVersionMinMinor(VMC, false));
645 uint32_t Update = MachOObjectFile::getVersionMinUpdate(VMC, false);
646 if (Update != 0)
647 Version += "." + utostr(MachOObjectFile::getVersionMinUpdate(VMC,
648 false));
649 W.printString("Version", Version);
650 SmallString<32> SDK;
651 if (VMC.sdk == 0)
652 SDK = "n/a";
653 else {
654 SDK = utostr(MachOObjectFile::getVersionMinMajor(VMC, true)) + "." +
655 utostr(MachOObjectFile::getVersionMinMinor(VMC, true));
656 uint32_t Update = MachOObjectFile::getVersionMinUpdate(VMC, true);
657 if (Update != 0)
658 SDK += "." + utostr(MachOObjectFile::getVersionMinUpdate(VMC,
659 true));
660 }
661 W.printString("SDK", SDK);
662 }
663 }
664 }
5555
5656 // Only implemented for MachO.
5757 virtual void printMachODataInCode() { }
58 virtual void printMachOVersionMin() { }
5859
5960 virtual void printStackMap() const = 0;
6061
185185 MachODataInCode("macho-data-in-code",
186186 cl::desc("Display MachO Data in Code command"));
187187
188 // -macho-version-min
189 cl::opt
190 MachOVersionMin("macho-version-min",
191 cl::desc("Display MachO version min command"));
188192 // -stackmap
189193 cl::opt
190194 PrintStackMap("stackmap",
319323 if (Obj->isMachO())
320324 if (opts::MachODataInCode)
321325 Dumper->printMachODataInCode();
326 if (opts::MachOVersionMin)
327 Dumper->printMachOVersionMin();
322328 if (opts::PrintStackMap)
323329 Dumper->printStackMap();
324330 }