MIPS patch to avoid lazy binding in la macros
Richard Sandiford
rsandifo@redhat.com
Mon Feb 24 15:07:00 GMT 2003
"Maciej W. Rozycki" <macro@ds2.pg.gda.pl> writes:
> Well, it's a "bug by design" or IOW a feature. Gccs used not to emit
> code sequences that would end up with an incorrect relocation. If that
> changed meanwhile, blame for gcc for not accounting for the behaviour of
> gas. The code is there since around 2.10, IIRC.
Indeed, historical precedent seems to be the main reason for not
changing things now.
> > > Essentially you kill lazy binding for code as currently emitted by gcc
> > > entirely this way.
> >
> > True. I'm getting used to mips-rewrite, so I forgot what older gccs
> > (including trunk ;) do. But more below.
>
> So what does exactly the branch do to select between GOT and CALL
> relocations?
Just to be clear, I'm talking about the gcc mips-3_4-rewrite-branch here.
It has two modes: one which uses assembler macros (as current gcc does)
and one that uses explicit %reloc() operators. When using assembler
macros, it gets lazy binding by using "jal foo".
> > Yes, the problem I came across was with undefined weak symbols.
>
> What version of gcc?
mips-3_4-rewrite-branch, in the "assembler macro" mode.
> > As I understand it, the idea behind the old behaviour was that
> > gcc generated:
> >
> > la $25,foo
> > jal $31,$25
> >
> > and we wanted GAS to treat "la $25,foo" as part of a call sequence.
>
> Any "la $25,foo" actually as gcc used not to use the register for
> anything else when emitting SVR4 PIC code.
Are you sure? What stopped gcc from using $25 for anything else?
Was it declared to be a fixed register?
As far as I'm aware, recent gccs have treated $25 as an ordinary
call-clobbered GPR.
> > Well, the code is still raw, but mips-rewrite does what you suggest,
> > at least for n32 and n64 PIC. There's a patch (pending review ;) to
> > extend it to o32 PIC as well.
>
> Too bad you haven't sent it earlier here -- maybe someone would be
> interested and would fix the problem for real. For now here is what I
> cooked up -- since it's been on my to-do list for at least two years, it
> certainly deserved being finally written. ;-) For 2.13.2.1 for now. I'll
> update that if that proves usable.
To be clear, I'm talking about a gcc patch here, not a gas patch.
CVS gas already has support for explicit relocations, see:
http://sources.redhat.com/ml/binutils/2003-01/msg00449.html
http://sources.redhat.com/ml/binutils/2003-02/msg00044.html
(...and various follow-ons ;)
Richard
More information about the Binutils
mailing list