Skip to content

Commit c2885de

Browse files
committed
Print dylib load kind (weak, reexport, etc) in llvm-objdump -m -dylibs-used
Summary: Historically llvm-objdump prints the path to a dylib as well as the dylib's compatibility version and current version number. This change extends this information by adding the kind of dylib load: weak, reexport, etc. rdar://51383512 Reviewers: pete, lhames Reviewed By: pete Subscribers: rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62866 llvm-svn: 363746
1 parent d11ea2c commit c2885de

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
RUN: llvm-objdump -m -dylibs-used %p/Inputs/hello.exe.macho-x86_64 | FileCheck %s -check-prefix=USED
2-
RUN: llvm-objdump -m -dylib-id %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=ID
3-
RUN: llvm-objdump -m -dylib-id -no-leading-headers %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=IDNOHEADERS
4-
1+
RUN: llvm-objdump -m -dylibs-used %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=USED
2+
USED: /usr/lib/foo1.dylib (compatibility version 0.0.0, current version 0.0.0)
3+
USED: /usr/lib/foo2.dylib (compatibility version 0.0.0, current version 0.0.0, weak)
4+
USED: /usr/lib/foo3.dylib (compatibility version 0.0.0, current version 0.0.0, reexport)
5+
USED: /usr/lib/foo4.dylib (compatibility version 0.0.0, current version 0.0.0, lazy)
56
USED: /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
67

8+
RUN: llvm-objdump -m -dylib-id %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=ID
79
ID: /usr/lib/foo.dylib
810

11+
RUN: llvm-objdump -m -dylib-id -no-leading-headers %p/Inputs/dylibLoadKinds.macho-x86_64 | FileCheck %s -check-prefix=IDNOHEADERS
912
IDNOHEADERS-NOT: dylibLoadKinds.macho-x86_64:
1013
IDNOHEADERS: /usr/lib/foo.dylib

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,16 @@ static void PrintDylibs(MachOObjectFile *O, bool JustId) {
12061206
outs() << " current version "
12071207
<< ((dl.dylib.current_version >> 16) & 0xffff) << "."
12081208
<< ((dl.dylib.current_version >> 8) & 0xff) << "."
1209-
<< (dl.dylib.current_version & 0xff) << ")\n";
1209+
<< (dl.dylib.current_version & 0xff);
1210+
if (Load.C.cmd == MachO::LC_LOAD_WEAK_DYLIB)
1211+
outs() << ", weak";
1212+
if (Load.C.cmd == MachO::LC_REEXPORT_DYLIB)
1213+
outs() << ", reexport";
1214+
if (Load.C.cmd == MachO::LC_LOAD_UPWARD_DYLIB)
1215+
outs() << ", upward";
1216+
if (Load.C.cmd == MachO::LC_LAZY_LOAD_DYLIB)
1217+
outs() << ", lazy";
1218+
outs() << ")\n";
12101219
}
12111220
} else {
12121221
outs() << "\tBad offset (" << dl.dylib.name << ") for name of ";

0 commit comments

Comments
 (0)