From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17745 invoked by alias); 11 Aug 2005 13:51:14 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17733 invoked by uid 22791); 11 Aug 2005 13:51:09 -0000 Received: from smtp-vbr12.xs4all.nl (HELO smtp-vbr12.xs4all.nl) (194.109.24.32) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 11 Aug 2005 13:51:09 +0000 Received: from xs2.xs4all.nl (xs2.xs4all.nl [194.109.21.3]) by smtp-vbr12.xs4all.nl (8.13.3/8.13.3) with ESMTP id j7BDp6CJ008164; Thu, 11 Aug 2005 15:51:06 +0200 (CEST) (envelope-from v-overbeek@cistron.nl) Received: from xs2.xs4all.nl (voverbee@localhost [127.0.0.1]) by xs2.xs4all.nl (8.13.3/8.12.11) with ESMTP id j7BDp63W017744; Thu, 11 Aug 2005 15:51:06 +0200 (CEST) (envelope-from v-overbeek@cistron.nl) Received: from localhost (voverbee@localhost) by xs2.xs4all.nl (8.13.3/8.12.11/Submit) with ESMTP id j7BDp68k017741; Thu, 11 Aug 2005 15:51:06 +0200 (CEST) (envelope-from v-overbeek@cistron.nl) Date: Thu, 11 Aug 2005 13:51:00 -0000 From: Ton van Overbeek X-X-Sender: voverbee@xs2.xs4all.nl To: =?ISO-8859-1?Q?Stefan_Burstr=F6m?= , Andreas Schwab cc: gdb@sources.redhat.com Subject: Re: Relocation question Message-ID: <20050811153614.N16092-100000@xs2.xs4all.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-SW-Source: 2005-08/txt/msg00056.txt.bz2 Andreas Schwab wrote: >Stefan Burstr=F6m writes: > >> Can someone explain to me how gdb is supposed to handle relocated >> executables? I am porting gdb to AmigaOS4 which relocates its >> executables >> when they are loaded. However, when I run an application through gdb, >> gdb uses the bfd functions to build its map over the file. However, the >> bfd library always relocates everything relative to 0 (since it >> obviously doesn't know anything else to relocate it to) > > That reminds me of an old port of gdb 3.6 for the AtariST (which has the > same problem). It used CREATE_INFERIOR_HOOK (now called > TARGET_CREATE_INFERIOR_HOOK) to query the load address of the just > started > process and then patched the gdb symtabs and breakpoint addresses by the > load offset. But I don't think that would still work nowadays. Have a look at how we solved this in prc-tools for PalmOS: http://prc-tools.sourceforge.net. Go to the cvs and look at the patch for gdb. It is for gdb 5.3, but the mechanism still works for 6.x. PalmOS can also have multiple code sections whose start addresses are not known untill runtime. A patch supporting that is on http://www.v-overbeek.nl/msectgdb. Basically when execution starts (either on a real PalmOS device or on an emulator) the start addresses of the .text and .data and other code sections are reported to gdb, which then relocates the symbol tables. (PalmOS is also m68k). Hope this helps. Ton van Overbeek (for Andreas: my first Linux experience was with Linux-68k on Atari-TT) (for Stefan: gjorde mitt examensarbete p=E5 LTH, Reglerteknik)