This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: dwarf2 and linker relaxation problem


Ian Lance Taylor <ian@airs.com> writes:
> Jim Blandy <jimb@redhat.com> writes:
>> Ian Lance Taylor <ian@airs.com> writes:
>> > Dmitry Diky <ddiky@alarity.com> writes:
>> >> I am experiencing some problems with keeping dwarf2 info intact after linker 
>> >> relaxation. So, if linker relax section, the line info references are shifted 
>> >> by the number of deleted bytes. 
>> >> Is there any example which shows how to fix this problem?
>> >
>> > I believe this works on the SH.  See sh_elf_relax_delete_bytes in
>> > elf32-sh.c.
>> 
>> Which part of that affects the .debug_line sections?
>
> The part that handles the R_SH_SWITCH* relocs.
>
> Not that I've checked it, but that's the right place to look.

These days the assembler produces .debug_line sections that use the
Dwarf special opcodes:

    $ readelf -wl bfd/archive.o
    ...
     Line Number Statements:
      Extended opcode 2: set Address to 0x0
      Advance Line by 161 to 162
      Copy
      Special opcode 92: advance Address by 6 to 0x6 and Line by 3 to 165
      Advance PC by constant 17 to 0x17
      Special opcode 62: advance Address by 4 to 0x1b and Line by 1 to 166
      Advance PC by constant 17 to 0x2c
    ...
    $

If the linker changes the length of an instruction between 0 and 6,
say, then that Dwarf special opcode needs to be changed.  I don't see
how any existing SH reloc could be shoehorned into fixing that.  And
then, since the special opcodes only have limited ranges, a relaxation
could require you to switch from a special opcode to something more
general, like a DW_LNS_advance_pc.

This is why, as Richard says, in order to do relaxation in the
presence of modern Dwarf line info, the linker needs to read the line
number info, do the relaxations while adjusting the machine / source
mapping as needed, and then re-emit the line number info.

I didn't see anything to do this in the BFD code --- thus my question.


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