This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Relaxation and .debug_loc section
- From: Michael Eager <eager at eagercon dot com>
- To: Bob Wilson <bwilson at tensilica dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 16 Jul 2007 10:45:29 -0700
- Subject: Re: Relaxation and .debug_loc section
- References: <469BA744.4080201@tensilica.com>
Bob Wilson wrote:
Michael Eager wrote:
There's no way to do that. The offsets are simple expressions.
The assembler converts them to integer values.
Getting the assembler to emit relocations is straightforward, but the
default DWARF encoding for line numbers is not easily relaxable, at
least if you have variable-size instructions. The PC and line number
offsets are encoded into a state machine, so that if the linker changes
some offsets, it probably needs to reencode all the line number info.
It's possible to have GCC generate line number references directly,
rather than generating .loc directives for the assembler.
See DWARF2_ASM_LINE_DEBUG_INFO.
Since there are explicit references to locations in the object code,
there are relocations. The relaxation pass can fix up these references.
Maybe there's some clever way out of that, but you might want to have a
look at the DWARF2_USE_FIXED_ADVANCE_PC macro that I added for Xtensa.
It tells GAS to use DWARF's fixed_advance_pc opcodes -- they are not as
compact as the default but you can put relocations on them so the linker
can easily adjust them when relaxation changes offsets.
I believe that when GCC generates the line table it does more or less
the same thing.
If you're ever able to contribute the code you wrote to have the linker
do relaxation without all the relocations, I'd be quite interested to
see it. We're just using lots of relocations for Xtensa, and so far it
hasn't been an issue, but I'm curious to see how else you could do it.
The code I wrote fixes the .debug_loc section, which contains location
lists. This is different from .debug_line section, which contains the
line table.
It should not be difficult to fix the line table, and I probably
would have done that if GCC didn't have the option to generate line
table entries with relocations. It requires the linker to decode
the line table, fix the offsets, then regenerate it. At least half
of that code is in gas.
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077