This is the mail archive of the gdb@sourceware.org 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: Relocation question


Andreas Schwab wrote:

>Stefan Burström <f94sbu@efd.lth.se> 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å LTH, Reglerteknik)


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