public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH bfin] Allow gas to adjust FDPIC GOT relocations
@ 2009-09-01  6:07 Jie Zhang
  0 siblings, 0 replies; only message in thread
From: Jie Zhang @ 2009-09-01  6:07 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]

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

[-- Attachment #2: gas-bfin-fix-adjustable.diff --]
[-- Type: text/x-patch, Size: 1005 bytes --]


	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:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-01  6:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-01  6:07 [PATCH bfin] Allow gas to adjust FDPIC GOT relocations Jie Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).