From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28407 invoked by alias); 30 Jan 2008 18:28:04 -0000 Received: (qmail 28384 invoked by uid 22791); 30 Jan 2008 18:28:04 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 30 Jan 2008 18:27:47 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.1/8.14.1) with ESMTP id m0UIRcUI026799; Wed, 30 Jan 2008 19:27:38 +0100 (CET) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.1/8.14.1/Submit) id m0UIRbv7029099; Wed, 30 Jan 2008 19:27:37 +0100 (CET) Date: Wed, 30 Jan 2008 18:28:00 -0000 Message-Id: <200801301827.m0UIRbv7029099@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: eager@eagercon.com CC: gdb@sourceware.org In-reply-to: <47A0A8D8.7090508@eagercon.com> (message from Michael Eager on Wed, 30 Jan 2008 08:42:00 -0800) Subject: Re: Finding ld.so dynamic loader References: <47A0A8D8.7090508@eagercon.com> 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: 2008-01/txt/msg00342.txt.bz2 > Date: Wed, 30 Jan 2008 08:42:00 -0800 > From: Michael Eager > > I've been reading through solib_open() in solib.c and the way > that the code searches for the dynamic loader doesn't make sense > to me, especially when using gdbserver to debug a program on > a remote system. Perhaps someone can explain to me why it is correct. > > solib_open() is called by enable_break() with the name of > the dynamic loader, say, "/lib/ld.so.1". The comments at > the top of solib_open() say: > > 125 * If there is a solib_absolute_prefix and path is absolute: > 126 * Search for solib_absolute_prefix/path. > 127 * else > 128 * Look for it literally (unmodified). > 129 * Look in SOLIB_SEARCH_PATH. > 130 * If available, use target defined search function. > 131 * If solib_absolute_prefix is NOT set, perform the following two searches: > 132 * Look in inferior's $PATH. > 133 * Look in inferior's $LD_LIBRARY_PATH. > > If solib_absolute_prefix is empty (true for almost all targets) and > /lib/ld.so.1 exists on the host system, this will be opened in > preference to either one specified on the SOLIB_SEARCH_PATH or using a > target search path. > > This seems incorrect. The dynamic loader on the host system > may not be the same as on the target system, and in the case > of cross development, may not even have the same architecture. > Shouldn't the search using the unmodified name be the last choice, > not the first? > > Can someone explain to me how gdb is supposed to find the correct > ld.so or why I'm looking at this incorrectly? Oh that's an easy one. GDB got corrupted by the embedded crowd who can't settle on a single way to build and install a cross toolchain. GDB tries to please them all, and still tries to cover the case of a native debugger too. Oh, by the way, you're looking at an old GDB version; we also have GDB_SYSROOT now.