This is the mail archive of the
mailing list for the binutils project.
Problem with gdb relocation of debug info
- From: Mattias Bertilsson <mattias dot bertilsson at enea dot com>
- To: gdb at sourceware dot org, binutils at sourceware dot org
- Date: Sat, 17 Jun 2006 14:43:24 +0200
- Subject: Problem with gdb relocation of debug info
We're working on a gdb port for the OSE rtos. We have run into a problem
with how gdb/bfd handles relocation information for the debug info and
would much appreciate ideas on how to fix it.
OSE relocatable executable elf files are linked to an absolute address,
but still have relocation information (so that the runtime loader can
move .text .bss, etc and patch as appropriate). To be specific we do:
ld -o [intermediate] -r [objs] --start-group [libs] --end-group --cref
ld -o [exe] [intermediate] -T [lcf] -n --emit-relocs -e [crt0] --cref
Now, in our gdb backend we fetch the real section addresses at runtime,
when we supply the symbol file to the rest of gdb. This works well for
powerpc, but fails for arm and mips, where gdb will get the address
wrong for all symbols that have debug info.
It seems the reason is the relocation of the .debug_info section that is
initiated in symfile_relocate_debug_section() in gdb/symfile.c and the
definition of the "howto" structs in bfd/elf32-mips.c and
For powerpc, src_mask is 0, so for relocations such as R_PPC_ADDR32 the
DOIT() macro in bfd_perform_relocation() in bfd/relocate.c will
correctly replace what was at the patch location with the new value.
For arm and mips, however, src_mask often equals dest_mask, even for
relocations that should patch in a constant value (such as R_ARM_ABS32).
The result for us, where the value at the patch location is not 0, is
that we, instead of patching in a constant, end up with the sum of
whatever was at the patch location and the new value.
What is the best solution to this? Change src_mask to 0 for all
relocations that should patch in constant values (which ones)? Or would
that just break something else?
We have been working with gdb 6.3 and binutils 2.15, but I believe this
issue is the same with newer versions.