Distributing rpath in library fails

Short question: Are rpaths commands from LC_RPATH inside the library passed to subsequent (and indirect) dynamically loaded libraries?

More precisely: My libapi.dylib dynamically linked to libloader.dylib , which dynamically loads the libplugin.dylib plugin. I have:

 $ otool -l lib/libapi.dylib lib/libapi.dylib libapi.dylib /usr/lib/libSystem.B.dylib @rpath/libloader.dylib $ otool -l lib/libloader.dylib lib/libloader.dylib libloader.dylib /usr/lib/libSystem.B.dylib $ otool -l lib/plugins/libplugin.dylib lib/plugins/libplugin.dylib: libplugin.dylib /usr/lib/libSystem.B.dylib @rpath/libloader.dylib $ otool -L lib/libapi.dylib | grep "LC_RPATH" -A2 cmd LC_RPATH cmdsize 32 path @loader_path/ (offset 12) 

Neither libloader.dylib nor libplugin.dylib sets the rpath command. And installation names do not have any @ rpath / paths or other paths, although names in boot commands are added using @ rpath /.

The client now downloads libapi.dylib , which in turn is associated with libloader.dylib . This library dynamically loads libplugin.dylib , which is associated with libloader.dylib .

Why can't libplugin.dylib be loaded? It leaves because it cannot find libloader.dylib - although it should already be loaded. Why doesn't the path rpath @ loader_path / from libapi.dylib properly extend to libloader.dylib before libplugin.dylib ? Using the DYLD_PRINT_RPATHS environment variable, I see that no rpath substitution is used to load libloader.dylib into libplugin.dylib . What's going on here?

+6
source share

Source: https://habr.com/ru/post/973776/


All Articles