This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why GDB ignores relative RPATH to find shared libraries?

On Fri, 19 Nov 2010 02:31:11 +0100, Ansis Atteka wrote:
> It seems that GDB favours the paths to shared libraries specified in
> coredump file instead of those specified in executable

It does not favor them but it never reads them at all.  GDB uses only the
_r_debug inferior shared library list.

rm -rf xbin xlib core.*;mkdir xbin xlib;:|gcc -x c - -shared -fPIC -o xlib/ -Wl,-soname,;echo 'main(){*(int*)0=0;}'|gcc -o xbin/bin -x c - -Lxlib -lx -Wl,-rpath,'$ORIGIN/../xlib';(ulimit -c unlimited;./xbin/bin);gdb -nx xbin/bin ./core.*

define sharedlist
        set var $sharedlist_iter=_r_debug.r_map
        while ($sharedlist_iter)
                print $sharedlist_iter->l_name
                set var $sharedlist_iter=$sharedlist_iter->l_next

(gdb) sharedlist 
$5 = 0x35f0419a74 ""
$6 = 0x35f0419a74 ""
$7 = 0x7f56709fb7b0 "/home/jkratoch/t/libs/xbin/../xlib/"
$8 = 0x7f56709fbca0 "/lib64/"
$9 = 0x400200 "/lib64/"

There is no $ORIGIN present anywhere in the inferior's list of currently
loaded shared libraries.  (Not even in the glibc internal link_map structure.)

This is sometimes a problem you cannot put breakpoints (without just making
them `pending') into shared libraries before you `start' the program, as GDB
does not know which shared libraries may get loaded.
Filed RFE for it.

> and that is not portable for remote analysis.

Currently even never suggests when it used $ORIGIN:

LD_DEBUG=all ./xbin/bin 2>&1 |grep libx|grep -v symbol=
     26462: [0];  needed by ./xbin/bin [0]
     26462:	find [0]; searching
     26462:	  trying file=/home/jkratoch/t/libs/xbin/../xlib/tls/x86_64/
     26462:	  trying file=/home/jkratoch/t/libs/xbin/../xlib/tls/
     26462:	  trying file=/home/jkratoch/t/libs/xbin/../xlib/x86_64/
     26462:	  trying file=/home/jkratoch/t/libs/xbin/../xlib/
     26462: [0];  generating link map
     26462:	checking for version `GLIBC_2.2.5' in file /lib64/ [0] required by file /home/jkratoch/t/libs/xbin/../xlib/ [0]
     26462:	relocation processing: /home/jkratoch/t/libs/xbin/../xlib/ (lazy)
     26462:	binding file /home/jkratoch/t/libs/xbin/../xlib/ [0] to /lib64/ [0]: normal symbol `__cxa_finalize' [GLIBC_2.2.5]
     26462:	calling init: /home/jkratoch/t/libs/xbin/../xlib/

But GDB could it from DT_RPATH.

Filed RFE for it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]