This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Don't relocate R_MIPS_JALR against dynamic symbols
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 27 Aug 2009 12:08:38 -0700
- Subject: Re: [PATCH] Don't relocate R_MIPS_JALR against dynamic symbols
- References: <19088.18512.864347.894300@ropi.home> <87tyztw08a.fsf@firetop.home>
Richard Sandiford writes:
> Adam Nemet <anemet@caviumnetworks.com> writes:
> > Index: elfxx-mips.c
> > ===================================================================
> > RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
> > retrieving revision 1.257
> > diff -F^\([(a-zA-Z0-9_]\|#define\) -u -p -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.257 elfxx-mips.c
> > --- elfxx-mips.c 5 Aug 2009 21:17:51 -0000 1.257
> > +++ elfxx-mips.c 22 Aug 2009 17:55:10 -0000
> > @@ -5489,8 +5489,9 @@ mips_elf_calculate_relocation (bfd *abfd
> > case R_MIPS_JALR:
> > /* This relocation is only a hint. In some cases, we optimize
> > it into a bal instruction. But we don't try to optimize
> > - branches to the PLT; that will wind up wasting time. */
> > - if (h != NULL && h->root.plt.offset != (bfd_vma) -1)
> > + branches to symbols in shared object; those either go to the
> > + lazy stub or can only be resolved at run-time. */
> > + if (h != NULL && !h->root.def_regular)
> > return bfd_reloc_continue;
> > value = symbol + addend;
> > break;
>
> I agree this is an improvement, but couldn't we still end up
> using BAL when we shouldn't if:
>
> (a) the link is not -Bsymbolic
> (b) the function has a regular .o definition
> (c) no call references are lazily bound (either because the
> author decided to use %got* instead of %call*, or because
> -znow is in effect)
Right I found out about it too, the hard way:
http://sourceware.org/ml/binutils/2009-08/msg00501.html
> ? I think we want:
>
> if (h != NULL && !SYMBOL_CALLS_LOCAL (info, h))
>
> instead.
I'll try that. Should I check it in if it works (regtest, GCC bootstrap)?
Adam