This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Don't relocate R_MIPS_JALR against dynamic symbols
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: binutils at sourceware dot org
- Date: Sat, 22 Aug 2009 12:34:40 -0700
- Subject: [PATCH] Don't relocate R_MIPS_JALR against dynamic symbols
This was also found while regression testing the R_MIPS_JALR patch in GCC.
Current logic in mips_elf_calculate_relocation refuses to relocate a
R_MIPS_JALR if there is a lazy-stub defined for the symbol. If there is no
lazy-stub we're happy to perform the relocation which can of course still be
against a dynamic symbol.
The change below makes the check stricter.
Regtested with ld on mips64octeon-linux. Also the C-only bootstrap of the
R_MIPS_JALR GCC patch passes with these two BFD patches.
OK?
Adam
* elfxx-mips.c (mips_elf_calculate_relocation): Don't relocate
R_MIPS_JALR unless symbol is def_regular.
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;