From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25614 invoked by alias); 21 Apr 2011 22:30:03 -0000 Received: (qmail 25478 invoked by uid 22791); 21 Apr 2011 22:30:00 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Apr 2011 22:29:46 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 21 Apr 2011 15:29:45 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by fmsmga001.fm.intel.com with ESMTP; 21 Apr 2011 15:29:46 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id C8CA6180F0E; Thu, 21 Apr 2011 15:29:45 -0700 (PDT) Date: Thu, 21 Apr 2011 22:30:00 -0000 From: "H.J. Lu" To: binutils@sourceware.org Subject: PATCH: PR ld/12694: Local IFUNC symbol causes TEXTREL Message-ID: <20110421222945.GA20140@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-04/txt/msg00318.txt.bz2 It is OK to have relocations against local IFUNC symbols since linker will resolve them to their PLT entries. Checked it in. H.J. --- --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 225a3fb..4d98456 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,12 @@ 2011-04-21 H.J. Lu + PR ld/12694 + * elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC + symbols. + * elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise. + +2011-04-21 H.J. Lu + * elf32-i386.c (elf_i386_finish_dynamic_symbol): Return false on dynamic symbol error. * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 1bdc05e..bb79f89 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2384,6 +2384,10 @@ elf_i386_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; + /* Skip local IFUNC symbols. */ + if (h->forced_local && h->type == STT_GNU_IFUNC) + return TRUE; + eh = (struct elf_i386_link_hash_entry *) h; for (p = eh->dyn_relocs; p != NULL; p = p->next) { diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 6190a98..8d00edd 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2299,6 +2299,10 @@ elf_x86_64_readonly_dynrelocs (struct elf_link_hash_entry *h, if (h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; + /* Skip local IFUNC symbols. */ + if (h->forced_local && h->type == STT_GNU_IFUNC) + return TRUE; + eh = (struct elf_x86_64_link_hash_entry *) h; for (p = eh->dyn_relocs; p != NULL; p = p->next) { diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a9f6083..7a09d41 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2011-04-21 H.J. Lu + + PR ld/12694 + * ld-ifunc/ifunc-14-i386.d: New. + * ld-ifunc/ifunc-14-x86-64.d: Likewise. + * ld-ifunc/ifunc-14a.s: Likewise. + * ld-ifunc/ifunc-14b.s: Likewise. + 2011-04-19 H.J. Lu * ld-plugin/plugin-ignore.d: Removed. diff --git a/ld/testsuite/ld-ifunc/ifunc-14-i386.d b/ld/testsuite/ld-ifunc/ifunc-14-i386.d new file mode 100644 index 0000000..0edc9fb --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-14-i386.d @@ -0,0 +1,11 @@ +#source: ifunc-14a.s +#source: ifunc-14b.s +#ld: -shared -m elf_i386 -z nocombreloc +#as: --32 +#readelf: -d --wide +#target: x86_64-*-* i?86-*-* + +#failif +#... +.*\(TEXTREL\).* +#... diff --git a/ld/testsuite/ld-ifunc/ifunc-14-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-14-x86-64.d new file mode 100644 index 0000000..2c4ebbb --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-14-x86-64.d @@ -0,0 +1,11 @@ +#source: ifunc-14a.s +#source: ifunc-14b.s +#ld: -shared -m elf_x86_64 -z nocombreloc +#as: --64 +#readelf: -d +#target: x86_64-*-* + +#failif +#... +.*\(TEXTREL\).* +#... diff --git a/ld/testsuite/ld-ifunc/ifunc-14a.s b/ld/testsuite/ld-ifunc/ifunc-14a.s new file mode 100644 index 0000000..9f20604 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-14a.s @@ -0,0 +1,7 @@ + .text + .globl bar + .type bar, @function +bar: + jmp foo + .size bar, .-bar + .hidden foo diff --git a/ld/testsuite/ld-ifunc/ifunc-14b.s b/ld/testsuite/ld-ifunc/ifunc-14b.s new file mode 100644 index 0000000..bac22eb --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-14b.s @@ -0,0 +1,5 @@ + .type foo, %gnu_indirect_function + .globl foo +foo: + ret + .size foo, .-foo