public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Bob Wilson <bwilson@tensilica.com>
To: binutils@sources.redhat.com
Subject: DWARF updates for linker relaxation?
Date: Mon, 17 Jul 2006 21:32:00 -0000	[thread overview]
Message-ID: <44BC01FE.1010303@tensilica.com> (raw)

I recently discovered a problem on Xtensa regarding DWARF line numbers and 
linker relaxation.  I'm not sure, but it looks like the same issue may exist for 
SH and possibly other ports that do link-time relaxation.  Before I go too far 
trying to solve this, I'd like to see if anyone has already looked at it, or if 
anyone has suggestions for solutions.

Link-time relaxation for Xtensa may cause some instructions to be deleted.  We 
rely on the assembler's (Xtensa-specific) -link-relax option to produce 
relocations for all text offsets that may change.  The thing we're missing is 
the address offsets in .debug_line sections (e.g., "special opcodes" that 
advance the address by a certain amount).  The assembler does not emit 
relocations for these offsets, and the linker does not adjust them when deleting 
instructions.

This problem went unnoticed for a while, because Tensilica's compiler produces 
its own DWARF that has relocations for the address offsets.  It isn't clear to 
me whether the DWARF generated by the assembler has ever worked with link-time 
relaxation on Xtensa, or if this is a regression caused by some change in the 
assembler.

I've looked around in the code to see if anyone else has dealt with this, and it 
looks like the SH port has code related to this.  See, for example, the 
sh_elf_relax_delete_bytes() function, which appears to be used to delete an 
instruction during linker relaxation.  That function contains this comment: 
"Dwarf line numbers use R_SH_SWITCH32 relocs."  This makes sense to me, since 
those relocs can represent an address offset, and the linker can look for those 
relocs to update the DWARF information.  The problem is that I can't find 
anything in the SH port of the assembler that would cause SWITCH32 relocs to be 
use for DWARF line numbers.  When I run the SH assembler, I don't see any of 
these relocations in the .debug_line section, either.

How do I make this work?  It seems like the obvious approach is to have a hook 
in the assembler to make it use the generic "advance_pc" opcode instead of 
"special opcodes", with relocations on the address offset fields.  The SH code 
mentioned above made me think there might already be code for this somewhere in 
the assembler, but I haven't found it.

Any suggestions?

--Bob

             reply	other threads:[~2006-07-17 21:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-17 21:32 Bob Wilson [this message]
2006-07-28 23:28 ` Bob Wilson
2006-08-08 10:16   ` Nick Clifton
2006-08-09  0:12     ` Bob Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44BC01FE.1010303@tensilica.com \
    --to=bwilson@tensilica.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).