This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: .reloc improvement
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org, Richard Sandiford <rdsandiford at googlemail dot com>
- Date: Tue, 6 Sep 2011 02:04:21 +0100 (BST)
- Subject: Re: .reloc improvement
- References: <20110818140817.GA14709@bubble.grove.modra.org> <87hb5c53pn.fsf@firetop.home> <20110821041645.GA18554@bubble.grove.modra.org> <alpine.DEB.1.10.1108210541070.5068@tp.orcam.me.uk> <20110822050332.GB18554@bubble.grove.modra.org>
On Mon, 22 Aug 2011, Alan Modra wrote:
> > Please note that on REL MIPS targets local symbols have to be retained in
> > several cases where crucial information is lost if a relocation against
> > such a symbol is converted to one against the containing section's symbol.
> > This applies to all the PC-relative relocations, where the relocatable
> > field is too narrow to hold arbitrary addends, and also, more recently, to
> > microMIPS targets, where linker relaxation has to know local symbol
> > (label) addresses to perform branch displacement recalculations and to
> > make the LUI/ADDIU->ADDIUPC relaxation. The latter is a linker's internal
> > limitation and may possibly be lifted (possibly by using the RELA
> > representation internally even on REL targets), but the former is an
> > inherent problem of the object file format used.
> >
> > Just making sure these issues are not missed -- I can't have a look at
> > your change at the moment and see what exact implications it has, sorry.
>
> The implication of my change is that the programmer will need to be
> careful in choosing symbols used with .reloc. While that isn't ideal,
> .reloc is such a low-level interface that you need to know what you're
> doing if you use it.
Problem is on REL targets some MIPS relocation types can never ever be
safely converted to refer to a section symbol + addend instead of the
intended symbol. You'd therefore make .reloc useless for these types.
Yes, REL shouldn't have been chosen for the MIPS ABI in the first place,
with the complication observed here being the tip of an iceberg only, but
there you go. The choice was later fixed with the new ABIs made for
64-bit MIPS processors, but the old ABI still remains for 32-bit ones.
> Alternatively, I'm quite willing to disable the symbol to section symbol
> conversion for REL targets.
Good idea, that sounds like a plan to me. That could be made platform
specific if that made anybody's life easier.
Maciej