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: Thu, 27 Oct 2011 20:09:24 +0100
- 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> <alpine.DEB.1.10.1109060149280.20410@tp.orcam.me.uk>
Hi Alan,
On Tue, 6 Sep 2011, Maciej W. Rozycki wrote:
> 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.
Where are we with this problem? Your change regressed this program (an
excerpt from a test case I prepared a while ago and was about to integrate
with our test suite):
$ cat reloc.s
.text
.fill 0x1000000
.set micromips
foo:
nop32
.reloc ., R_MICROMIPS_PC23_S2, 0f
.fill 0
addiu $2, $pc, 8
nop32
0:
from this:
$ mips-sde-elf-as -32 -o reloc.o reloc.s
$ mips-sde-elf-objdump -dr reloc.o
reloc.o: file format elf32-tradbigmips
Disassembly of section .text:
00000000 <foo-0x1000000>:
...
01000000 <foo>:
1000000: 0000 0000 nop
1000004: 7900 0002 addiu v0,$pc,8
1000004: R_MICROMIPS_PC23_S2 .L1
1000008: 0000 0000 nop
to this:
$ mips-sde-elf-as -o reloc.o reloc.s
reloc.s: Assembler messages:
reloc.s:8: Error: relocation overflow
Maciej