Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 653586

Summary: app-misc/pax-utils: lddtree: Incomplete support for relative DT_RPATH / DT_RUNPATH
Product: Gentoo Linux Reporter: Arfrever Frehtes Taifersar Arahesis <arfrever.fta>
Component: Current packagesAssignee: Sergei Trofimovich <slyfox>
Status: CONFIRMED ---    
Severity: normal CC: toolchain
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---

Description Arfrever Frehtes Taifersar Arahesis 2018-04-20 01:51:14 UTC
$ mkdir -p /tmp/tests
$ cd /tmp/tests
$ mkdir dir
$ gcc -shared -fPIC -o libA.so -x c - < /dev/null
$ gcc -shared -fPIC -o dir/libB.so -x c - < /dev/null
$ gcc -o test1 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath, -Wl,-rpath,dir
$ gcc -o test2 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,. -Wl,-rpath,dir
$ gcc -o test3 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,dir/.. -Wl,-rpath,dir
$ gcc -o test4 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/dir'
$ gcc -o test5 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,'${ORIGIN}' -Wl,-rpath,'${ORIGIN}/dir'
$ gcc -o test6 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,'$ORIGIN/dir/..' -Wl,-rpath,'$ORIGIN/dir'
$ gcc -o test7 -x c - <<< "int main() {}" -L. -Ldir -lA -lB -Wl,-rpath,'${ORIGIN}/dir/..' -Wl,-rpath,'${ORIGIN}/dir'
$ 


DT_RUNPATH is set correctly:

$ scanelf -r test*
 TYPE   RPATH FILE 
ET_DYN :dir test1 
ET_DYN .:dir test2 
ET_DYN dir/..:dir test3 
ET_DYN $ORIGIN:$ORIGIN/dir test4 
ET_DYN ${ORIGIN}:${ORIGIN}/dir test5
ET_DYN $ORIGIN/dir/..:$ORIGIN/dir test6 
ET_DYN ${ORIGIN}/dir/..:${ORIGIN}/dir test7
$ 


All executables actually work:

$ ./test1
$ ./test2
$ ./test3
$ ./test4
$ ./test5
$ ./test6
$ ./test7
$ 


ldd tool (from sys-libs/glibc) finds libraries:

$ ldd test*
test1:
        linux-vdso.so.1 (0x00007ffcfad86000)
        libA.so (0x00007f349ae13000)
        libB.so => dir/libB.so (0x00007f349ac11000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f349a846000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f349b217000)
test2:
        linux-vdso.so.1 (0x00007ffed2344000)
        libA.so => ./libA.so (0x00007f639a872000)
        libB.so => dir/libB.so (0x00007f639a670000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f639a2a5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f639ac76000)
test3:
        linux-vdso.so.1 (0x00007ffdc0d30000)
        libA.so => dir/../libA.so (0x00007f8146b1b000)
        libB.so => dir/libB.so (0x00007f8146919000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f814654e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8146f1f000)
test4:
        linux-vdso.so.1 (0x00007ffc6f560000)
        libA.so => /tmp/tests/./libA.so (0x00007f2d1b9fe000)
        libB.so => /tmp/tests/./dir/libB.so (0x00007f2d1b7fc000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2d1b431000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f2d1be02000)
test5:
        linux-vdso.so.1 (0x00007ffcd198d000)
        libA.so => /tmp/tests/./libA.so (0x00007f0ef81b0000)
        libB.so => /tmp/tests/./dir/libB.so (0x00007f0ef7fae000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f0ef7be3000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f0ef85b4000)
test6:
        linux-vdso.so.1 (0x00007ffde2ff3000)
        libA.so => /tmp/tests/./dir/../libA.so (0x00007fb9112bf000)
        libB.so => /tmp/tests/./dir/libB.so (0x00007fb9110bd000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fb910cf2000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb9116c3000)
test7:
        linux-vdso.so.1 (0x00007fff8f190000)
        libA.so => /tmp/tests/./dir/../libA.so (0x00007f4749724000)
        libB.so => /tmp/tests/./dir/libB.so (0x00007f4749522000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f4749157000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4749b28000)
$


Following results with app-misc/pax-utils-1.2.3-r1:


lddtree (Python implementation, lddtree.py in pax-utils repository) supports '' (empty path), but not '.', supports '$ORIGIN', but not '${ORIGIN}' and does not support other relative paths:

$ lddtree test*
test1 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => /tmp/tests/libA.so
    libB.so => None
    libc.so.6 => /lib64/libc.so.6
test2 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => None
    libB.so => None
    libc.so.6 => /lib64/libc.so.6
test3 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => None
    libB.so => None
    libc.so.6 => /lib64/libc.so.6
test4 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => /tmp/tests/libA.so
    libB.so => /tmp/tests/dir/libB.so
    libc.so.6 => /lib64/libc.so.6
test5 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => None
    libB.so => None
    libc.so.6 => /lib64/libc.so.6
test6 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => /tmp/tests/libA.so
    libB.so => /tmp/tests/dir/libB.so
    libc.so.6 => /lib64/libc.so.6
test7 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => None
    libB.so => None
    libc.so.6 => /lib64/libc.so.6
$ 


lddtree (BASH implementation, lddtree.sh in pax-utils repository) does not support '' (empty path), supports '.', supports alone '$ORIGIN', but not '$ORIGIN/...', does not support '${ORIGIN}':

lddtree test*
test1 => ./test1 (interpreter => /lib64/ld-linux-x86-64.so.2)
scanelf: rpath_security_checks(): Security problem NULL DT_RUNPATH in ./test1
scanelf: rpath_security_checks(): Maybe? sec problem with DT_RUNPATH='dir' in ./test1
    libA.so => not found
scanelf: rpath_security_checks(): Security problem NULL DT_RUNPATH in ./test1
scanelf: rpath_security_checks(): Maybe? sec problem with DT_RUNPATH='dir' in ./test1
    libB.so => dir/libB.so
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test2 => ./test2 (interpreter => /lib64/ld-linux-x86-64.so.2)
scanelf: rpath_security_checks(): Security problem with relative DT_RUNPATH '.:dir' in ./test2
scanelf: rpath_security_checks(): Maybe? sec problem with DT_RUNPATH='dir' in ./test2
    libA.so => ./libA.so
    libB.so => dir/libB.so
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test3 => ./test3 (interpreter => /lib64/ld-linux-x86-64.so.2)
scanelf: rpath_security_checks(): Maybe? sec problem with DT_RUNPATH='dir/..:dir' in ./test3
scanelf: rpath_security_checks(): Maybe? sec problem with DT_RUNPATH='dir' in ./test3
    libA.so => dir/../libA.so
    libB.so => dir/libB.so
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test4 => ./test4 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => ./libA.so
    libB.so => not found
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test5 => ./test5 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => not found
    libB.so => not found
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test6 => ./test6 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => ./dir/../libA.so
    libB.so => not found
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
test7 => ./test7 (interpreter => /lib64/ld-linux-x86-64.so.2)
    libA.so => not found
    libB.so => not found
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
$
Comment 1 Sergei Trofimovich gentoo-dev 2018-04-20 06:12:01 UTC

*** This bug has been marked as a duplicate of bug 589434 ***
Comment 2 Arfrever Frehtes Taifersar Arahesis 2018-04-20 08:59:53 UTC
All problems in lddtree.py and at least one problem lddtree.sh are unrelated to scanelf.