summaryrefslogtreecommitdiff
path: root/tools/llvm-readobj/MachODumper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-readobj/MachODumper.cpp')
-rw-r--r--tools/llvm-readobj/MachODumper.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/llvm-readobj/MachODumper.cpp b/tools/llvm-readobj/MachODumper.cpp
index 39e90927993..64178d7b33a 100644
--- a/tools/llvm-readobj/MachODumper.cpp
+++ b/tools/llvm-readobj/MachODumper.cpp
@@ -39,6 +39,8 @@ public:
void printUnwindInfo() override;
void printStackMap() const override;
+ void printNeededLibraries() override;
+
// MachO-specific.
void printMachODataInCode() override;
void printMachOVersionMin() override;
@@ -675,6 +677,34 @@ void MachODumper::printStackMap() const {
StackMapV2Parser<support::big>(StackMapContentsArray));
}
+void MachODumper::printNeededLibraries() {
+ ListScope D(W, "NeededLibraries");
+
+ using LibsTy = std::vector<StringRef>;
+ LibsTy Libs;
+
+ for (const auto &Command : Obj->load_commands()) {
+ if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
+ Command.C.cmd == MachO::LC_ID_DYLIB ||
+ Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||
+ Command.C.cmd == MachO::LC_REEXPORT_DYLIB ||
+ Command.C.cmd == MachO::LC_LAZY_LOAD_DYLIB ||
+ Command.C.cmd == MachO::LC_LOAD_UPWARD_DYLIB) {
+ MachO::dylib_command Dl = Obj->getDylibIDLoadCommand(Command);
+ if (Dl.dylib.name < Dl.cmdsize) {
+ auto *P = static_cast<const char*>(Command.Ptr) + Dl.dylib.name;
+ Libs.push_back(P);
+ }
+ }
+ }
+
+ std::stable_sort(Libs.begin(), Libs.end());
+
+ for (const auto &L : Libs) {
+ outs() << " " << L << "\n";
+ }
+}
+
void MachODumper::printMachODataInCode() {
for (const auto &Load : Obj->load_commands()) {
if (Load.C.cmd == MachO::LC_DATA_IN_CODE) {