This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH bfin] Allow gas to adjust FDPIC GOT relocations
- From: Jie Zhang <jie dot zhang at analog dot com>
- To: binutils at sourceware dot org
- Date: Tue, 1 Sep 2009 14:07:18 +0800
- Subject: [PATCH bfin] Allow gas to adjust FDPIC GOT relocations
Hi,
Below is a test case.
-----------------
#include <stdio.h>
typedef int (*func)();
static int f()
{
return 0;
}
func a[] = {f, NULL};
int main(void)
{
func p = f;
func q = a[0];
printf("p=%x\nq=%x\n", p, q);
return 0;
}
----------------
p and q should be equal. GAS created a R_BFIN_FUNCDESC relocation for
f in a[] and a R_BFIN_FUNCDESC_GOT17M4 for f in main (). In a further
pass, GAS adjusted f in R_BFIN_FUNCDESC relocation to section name but
didn't for another f.
Relocation section '.rela.text' at offset 0x3c0 contains 4 entries:
Offset Info Type Sym.Value Sym. Name + Addend
0000001a 00000518 R_BFIN_FUNCDESC_G 00000000 _f + 0
Relocation section '.rela.data.rel.local' at offset 0x3f0 contains 1
entries:
Offset Info Type Sym.Value Sym. Name + Addend
00000000 00000217 R_BFIN_FUNCDESC 00000000 .text + 0
Then ld created two function descriptors, one for _f + 0 and the other
of .text + 0 and p and q were not equal.
This patch should fix it by allowing GAS to adjust
relocation. I don't think there is any reason why R_BFIN_GOT17M4
cannot be adjusted. So I changes it, too. Bernd pointed out that we
should keep BFD_RELOC_BFIN_GOT unadjustable, "as the linker is not
prepared to handle relocs of the form ".data+offset <at> GOT", it needs
a symbol. This is required for shared-flat."
Committed.
Jie
2007-09-28 Bernd Schmidt <bernd.schmidt@analog.com>
* config/tc-bfin.c (bfin_fix_adjustable): Partially revert the
2007-08-23 change; BFD_RELOC_BFIN_GOT is not adjustable.
2007-08-23 Jie Zhang <jie.zhang@analog.com>
* config/tc-bfin.c (bfin_fix_adjustable): Adjust
BFD_RELOC_BFIN_GOT, BFD_RELOC_BFIN_GOT17M4 and
BFD_RELOC_BFIN_FUNCDESC_GOT17M4.
Index: config/tc-bfin.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-bfin.c,v
retrieving revision 1.24
diff -u -p -r1.24 tc-bfin.c
--- config/tc-bfin.c 1 Sep 2009 00:24:01 -0000 1.24
+++ config/tc-bfin.c 1 Sep 2009 05:51:10 -0000
@@ -1005,8 +1005,6 @@ bfin_fix_adjustable (fixS *fixP)
{
/* Adjust_reloc_syms doesn't know about the GOT. */
case BFD_RELOC_BFIN_GOT:
- case BFD_RELOC_BFIN_GOT17M4:
- case BFD_RELOC_BFIN_FUNCDESC_GOT17M4:
case BFD_RELOC_BFIN_PLTPC:
/* We need the symbol name for the VTABLE entries. */
case BFD_RELOC_VTABLE_INHERIT: