[llvm-branch-commits] [llvm-branch] r322561 - Merging r321980:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 16 07:29:27 PST 2018
Author: hans
Date: Tue Jan 16 07:29:26 2018
New Revision: 322561
URL: http://llvm.org/viewvc/llvm-project?rev=322561&view=rev
Log:
Merging r321980:
------------------------------------------------------------------------
r321980 | phosek | 2018-01-07 18:23:10 -0800 (Sun, 07 Jan 2018) | 5 lines
[llvm-readobj] Support -needed-libs option for Mach-O files
This implements the -needed-libs option in Mach-O dumper.
Differential Revision: https://reviews.llvm.org/D41527
------------------------------------------------------------------------
Added:
llvm/branches/release_60/test/tools/llvm-readobj/macho-needed-libs.test
- copied unchanged from r321980, llvm/trunk/test/tools/llvm-readobj/macho-needed-libs.test
Modified:
llvm/branches/release_60/ (props changed)
llvm/branches/release_60/tools/llvm-readobj/MachODumper.cpp
Propchange: llvm/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 16 07:29:26 2018
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,321789,322103
+/llvm/trunk:155241,321789,321980,322103
Modified: llvm/branches/release_60/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/tools/llvm-readobj/MachODumper.cpp?rev=322561&r1=322560&r2=322561&view=diff
==============================================================================
--- llvm/branches/release_60/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/branches/release_60/tools/llvm-readobj/MachODumper.cpp Tue Jan 16 07:29:26 2018
@@ -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) {
More information about the llvm-branch-commits
mailing list