Skip local IFUNC symbols when checking dynamic relocs in read-only sections.
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 21 Apr 2011 22:25:39 +0000 (22:25 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 21 Apr 2011 22:25:39 +0000 (22:25 +0000)
bfd/

2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/12694
* elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC
symbols.
* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.

ld/testsuite/

2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>

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.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-ifunc/ifunc-14-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-14-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-14a.s [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-14b.s [new file with mode: 0644]

index 225a3fb40aba20e553154f0dcfdb520f8caab2d3..4d98456808827d80e561a9be179f593692b1ace2 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_finish_dynamic_symbol): Return false
index 1bdc05e9ae2a6495adaf1332288bc520ca880eb9..bb79f897d79f56836f5c78d7c2375798f5660c8f 100644 (file)
@@ -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)
     {
index 6190a988477f1741c6eafb5cee99945cd354c481..8d00eddb3da5699e8a6c2ef1409608594ea69260 100644 (file)
@@ -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)
     {
index a9f60839cc3606f7c7de9af05839fbfe2ca56c26..7a09d41d62b0c901d0f7290577e2b68a06316f13 100644 (file)
@@ -1,3 +1,11 @@
+2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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  <hongjiu.lu@intel.com>
 
        * 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 (file)
index 0000000..0edc9fb
--- /dev/null
@@ -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 (file)
index 0000000..2c4ebbb
--- /dev/null
@@ -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 (file)
index 0000000..9f20604
--- /dev/null
@@ -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 (file)
index 0000000..bac22eb
--- /dev/null
@@ -0,0 +1,5 @@
+       .type foo, %gnu_indirect_function
+       .globl foo
+foo:
+       ret
+       .size   foo, .-foo