RTLD DT_RUNPATH/DT_RPATH processing difference

Vyacheslav Barinov v.barinov@samsung.com
Wed Jun 28 10:08:00 GMT 2017


Hello,

Recently I started the migration from DT_RPATH to DT_RUNPATH in our distro in
order to make the LD_LIBRARY_PATH work the right way, and detected that these
two tags are processed differently in RTLD.

We have a loader which opens executables (pie ones) with dlopen() and then
calls main(). This approach allows to speedup running application with large
number library dependencies.

Usual application has the following structure:

app/
    bin/app
    lib/library.so

During the launch procedure 'bin/app' is opened by loader and executed through
the dlopen().

In order to load the application-specific library.so the directory is changed
to app/lib and 'loader' has DT_RPATH set to ":" to allow loading from current
working directory.

After changing DT_RPATH to DT_RUNPATH the mechanism stopped working. I
investigated the elf/dl-load.c and found that 'main_map' and dependent objects
rpaths are only checked in case of DT_RPATH tag.

Can someone tell if this behavior is intended or not?

I've prepared a patch to process these places for DT_RUNPATH and resolved the
launcher issue. The patch and reprocase are attached.

Best Regards,
Vyacheslav Barinov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-elf-Treat-DT_RUNPATH-exactly-like-DT_RPATH-in-rtld.patch
Type: text/x-diff
Size: 2312 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20170628/197baa96/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlopen-test.tar.xz
Type: application/x-xz
Size: 1424 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20170628/197baa96/attachment.xz>


More information about the Libc-help mailing list