From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5957 invoked by alias); 21 Nov 2010 18:26:49 -0000 Received: (qmail 5941 invoked by uid 22791); 21 Nov 2010 18:26:49 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 21 Nov 2010 18:26:44 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oALIQhIj007658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 21 Nov 2010 13:26:43 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oALIQf7v009307 for ; Sun, 21 Nov 2010 13:26:42 -0500 Received: from host0.dyn.jankratochvil.net (localhost.localdomain [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id oALIQd8V027483; Sun, 21 Nov 2010 19:26:39 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id oALIQZaG027482; Sun, 21 Nov 2010 19:26:35 +0100 Date: Sun, 21 Nov 2010 18:26:00 -0000 From: Jan Kratochvil To: Ansis Atteka Cc: gdb@sourceware.org Subject: Re: Why GDB ignores relative RPATH to find shared libraries? Message-ID: <20101121182635.GA24208@host0.dyn.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00083.txt.bz2 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/libx.so -Wl,-soname,libx.so;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 end end (gdb) sharedlist $5 = 0x35f0419a74 "" $6 = 0x35f0419a74 "" $7 = 0x7f56709fb7b0 "/home/jkratoch/t/libs/xbin/../xlib/libx.so" $8 = 0x7f56709fbca0 "/lib64/libc.so.6" $9 = 0x400200 "/lib64/ld-linux-x86-64.so.2" 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 http://sourceware.org/bugzilla/show_bug.cgi?id=12249 RFE for it. > and that is not portable for remote analysis. Currently even ld.so never suggests when it used $ORIGIN: LD_DEBUG=all ./xbin/bin 2>&1 |grep libx|grep -v symbol= 26462: file=libx.so [0]; needed by ./xbin/bin [0] 26462: find library=libx.so [0]; searching 26462: trying file=/home/jkratoch/t/libs/xbin/../xlib/tls/x86_64/libx.so 26462: trying file=/home/jkratoch/t/libs/xbin/../xlib/tls/libx.so 26462: trying file=/home/jkratoch/t/libs/xbin/../xlib/x86_64/libx.so 26462: trying file=/home/jkratoch/t/libs/xbin/../xlib/libx.so 26462: file=libx.so [0]; generating link map 26462: checking for version `GLIBC_2.2.5' in file /lib64/libc.so.6 [0] required by file /home/jkratoch/t/libs/xbin/../xlib/libx.so [0] 26462: relocation processing: /home/jkratoch/t/libs/xbin/../xlib/libx.so (lazy) 26462: binding file /home/jkratoch/t/libs/xbin/../xlib/libx.so [0] to /lib64/libc.so.6 [0]: normal symbol `__cxa_finalize' [GLIBC_2.2.5] 26462: calling init: /home/jkratoch/t/libs/xbin/../xlib/libx.so But GDB could it from DT_RPATH. Filed http://sourceware.org/bugzilla/show_bug.cgi?id=12250 RFE for it. Thanks, Jan