From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14104 invoked by alias); 29 Jul 2008 03:03:28 -0000 Received: (qmail 14092 invoked by uid 22791); 29 Jul 2008 03:03:27 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 29 Jul 2008 03:02:59 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id E4CDF17F5A3 for ; Mon, 28 Jul 2008 23:49:30 -0300 (BRT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m6T3301V2007104 for ; Tue, 29 Jul 2008 00:03:00 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m6T32qpx013752 for ; Tue, 29 Jul 2008 00:02:54 -0300 Received: from [9.8.11.76] ([9.8.11.76]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m6T32WCa013480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 29 Jul 2008 00:02:45 -0300 Subject: Re: [PATCH] Handle absence of DT_DEBUG while debugging ld.so From: Luis Machado Reply-To: luisgpm@linux.vnet.ibm.com To: Daniel Jacobowitz Cc: gdb-patches@sourceware.org In-Reply-To: <1217300235.16935.35.camel@gargoyle> References: <1217289278.16935.23.camel@gargoyle> <20080729022723.GA6298@caradoc.them.org> <1217300235.16935.35.camel@gargoyle> Content-Type: text/plain Date: Tue, 29 Jul 2008 03:03:00 -0000 Message-Id: <1217300562.16935.38.camel@gargoyle> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00534.txt.bz2 On Mon, 2008-07-28 at 23:57 -0300, Luis Machado wrote: > On Mon, 2008-07-28 at 22:27 -0400, Daniel Jacobowitz wrote: > > On Mon, Jul 28, 2008 at 08:54:37PM -0300, Luis Machado wrote: > > > Hi folks, > > > > > > When trying to debug ld.so, we may find that the DT_DEBUG entry in > > > the .dynamic section is missing, thus GDB tries to look for the _r_debug > > > minimal symbol, and eventually finds it. This works OK as long as the > > > _r_debug minimal symbol is correct and initialized. > > > > > > In the case where GDB fetches an uninitialized _r_debug minimal symbol > > > and tries to access its address, we have a memory access error, just > > > like below: > > > > > > (gdb) r > > > Starting program: /foo/lib/ld.so.1 > > > Cannot access memory at address 0x2f648 > > > > > > Thus, we should guard this piece of code against uninitialized addresses > > > so that GDB can skip this entry and look for another (hopefully) valid > > > _r_debug symbol. > > > > I think this is a PIE-related problem. It has nothing to do with > > uninitialized, because we're just taking the symbol's > > address; but the address you've got there looks wrong. It's as if > > ld.so was loaded at 0x0. How did that happen? > > Yes, this specific address seems broken somehow. This is the first > _r_debug entry GDB gets: > > $6 = {ginfo = {name = 0x10a10b70 "_r_debug", value = {ivalue = 194116, > block = 0x2f644, bytes = 0x2f644
, > address = 194116, chain = 0x2f644}, language_specific = > {cplus_specific = {demangled_name = 0x0}}, language = language_auto, > section = 20, bfd_section = 0x109ea688}, info = 0x0, size = 20, > filename = 0x10a09fe0 "rawmemchr.c", type = mst_bss, hash_next = 0x0, > demangled_hash_next = 0x0} > > And this is the next _r_debug minimal symbol entry GDB gets: > > $7 = {ginfo = {name = 0x10a10b70 "_r_debug", value = {ivalue = > 134411844, block = 0x802f644, > bytes = 0x802f644
, address = > 134411844, chain = 0x802f644}, language_specific = {cplus_specific = { > demangled_name = 0x0}}, language = language_auto, section = 20, > bfd_section = 0x109ea688}, info = 0x0, size = 20, > filename = 0x10a09fe0 "rawmemchr.c", type = mst_bss, hash_next = 0x0, > demangled_hash_next = 0x0} > > Now, i see the very same offset there, but now looks like it has been > shifted to a different address (ld's load address probably). > > So, that's why i was imagining it wasn't really initialized yet. > > Regards, > Luis btw, to reproduce it, just load ld.so into gdb and "run". You should see the problem. Luis