Reported dependency paths from otool are not the paths where the loader finds the dependencies
Asked Answered
Y

0

9

Hopefully this isn't a duplicate (I found a bunch of similar questions, but not exactly what I'm asking).

On linux when I run ldd <path/to/executable> I get a nice list of the shared library dependencies and the path were those dependencies are found by the dynamic linker (or a message that the dependency was not found).

On mac when using otool -L <path/to/executable> I get the dependencies and the paths are relative to the rpath, even if the dependency is not there. Essentially it's reporting where the dependency should be relative to the rpath instead of where it is discovered by the dynamic linker. From what I understand otool reads this information directly from the binary instead of invoking the linker like ldd.

I understand that I can get those paths by running the executable with the DYLD_PRINT_LIBRARIES variable set to 1, but this doesn't work for dynamic libraries and even for executables it's not convenient.

So my question is, can I get exactly the same behaviour as ldd in mac?

otool information:

➜  otool --version
llvm-otool(1): Apple Inc. version cctools-906
Apple LLVM version 9.1.0 (clang-902.0.39.1)
  Optimized build.
  Default target: x86_64-apple-darwin17.5.0
  Host CPU: ivybridge
Yemen answered 10/8, 2018 at 14:4 Comment(1)
This still seems to be the case nearly 6 years later. otool --version llvm-otool(1): Apple Inc. version cctools-1009.3 otool(1): Apple Inc. version cctools-1009.3 disassmbler: LLVM version 15.0.0Hurrah

© 2022 - 2024 — McMap. All rights reserved.