From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17507 invoked by alias); 1 Sep 2009 06:07:40 -0000 Received: (qmail 17499 invoked by uid 22791); 1 Sep 2009 06:07:39 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from nwd2mail10.analog.com (HELO nwd2mail10.analog.com) (137.71.25.55) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Sep 2009 06:07:34 +0000 Received: from nwd2hubcas1.ad.analog.com ([10.64.73.29]) by nwd2mail10.analog.com with ESMTP; 01 Sep 2009 02:07:32 -0400 Received: from nwd2exm5.ad.analog.com (10.64.51.20) by NWD2HUBCAS1.ad.analog.com (10.64.73.29) with Microsoft SMTP Server id 8.1.358.0; Tue, 1 Sep 2009 02:07:31 -0400 Received: from nwd2exm20.ad.analog.com ([10.64.73.20]) by nwd2exm5.ad.analog.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Sep 2009 02:07:31 -0400 Received: from chinexm1.ad.analog.com ([10.99.27.42]) by nwd2exm20.ad.analog.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Sep 2009 02:07:31 -0400 Received: from [10.99.29.103] ([10.99.29.103]) by chinexm1.ad.analog.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 1 Sep 2009 14:07:27 +0800 Message-ID: <4A9CBA16.8020101@analog.com> Date: Tue, 01 Sep 2009 06:07:00 -0000 From: Jie Zhang User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: binutils@sourceware.org Subject: [PATCH bfin] Allow gas to adjust FDPIC GOT relocations Content-Type: multipart/mixed; boundary="------------020102090908060205090706" X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00012.txt.bz2 --------------020102090908060205090706 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1427 Hi, Below is a test case. ----------------- #include 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 GOT", it needs a symbol. This is required for shared-flat." Committed. Jie --------------020102090908060205090706 Content-Type: text/x-patch; name="gas-bfin-fix-adjustable.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gas-bfin-fix-adjustable.diff" Content-length: 1005 2007-09-28 Bernd Schmidt * 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 * 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: --------------020102090908060205090706--