]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Check local IFUNC calls
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 20 Dec 2012 18:51:10 +0000 (18:51 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 20 Dec 2012 18:51:10 +0000 (18:51 +0000)
bfd/

PR ld/14956
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Check local
IFUNC calls.
* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.

ld/testsuite/

PR ld/14956
* ld-ifunc/ifunc-14-i386.d: Renamed to ...
* ld-ifunc/ifunc-14a-i386.d: This.

* ld-ifunc/ifunc-14-x86-64.d: Renamed to ...
* ld-ifunc/ifunc-14a-x86-64.d: This.

* ld-ifunc/ifunc-14b-i386.d: New file.
* ld-ifunc/ifunc-14b-x86-64.d: Likewise.
* ld-ifunc/ifunc-14c-i386.d: Likewise.
* ld-ifunc/ifunc-14c-x86-64.d: Likewise.
* ld-ifunc/ifunc-14d-i386.d: Likewise.
* ld-ifunc/ifunc-14d-x86-64.d: Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-ifunc/ifunc-14-i386.d [deleted file]
ld/testsuite/ld-ifunc/ifunc-14-x86-64.d [deleted file]

index d6281e55730f059e11b28ff6ebf4083b22f46e6b..cfa358ca66202d53f514babbc34533b87bc647ba 100644 (file)
@@ -1,3 +1,10 @@
+2012-12-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14956
+       * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Check local
+       IFUNC calls.
+       * elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+
 2012-12-17  Roland McGrath  <mcgrathr@google.com>
            Alan Modra  <amodra@gmail.com>
 
index 7d3652d81ce983ae3499e279427c61feb6db557a..987416c57f71a423c43f66d03ff304f0750914a8 100644 (file)
@@ -2066,10 +2066,39 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info,
 {
   struct elf_i386_link_hash_table *htab;
   asection *s;
+  struct elf_i386_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
 
   /* STT_GNU_IFUNC symbol must go through PLT. */
   if (h->type == STT_GNU_IFUNC)
     {
+      /* Check local STT_GNU_IFUNC calls.  */
+      if (h->ref_regular
+         && SYMBOL_CALLS_LOCAL (info, h))
+       {
+         bfd_size_type pc_count = 0;
+         struct elf_dyn_relocs **pp;
+
+         eh = (struct elf_i386_link_hash_entry *) h;
+         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+           {
+             pc_count += p->pc_count;
+             p->count -= p->pc_count;
+             p->pc_count = 0;
+             if (p->count == 0)
+               *pp = p->next;
+             else
+               pp = &p->next;
+           }
+
+         if (pc_count)
+           {
+             h->needs_plt = 1;
+             h->plt.refcount += 1;
+             h->non_got_ref = 1;
+           }
+       }
+
       if (h->plt.refcount <= 0)
        {
          h->plt.offset = (bfd_vma) -1;
@@ -2155,9 +2184,6 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info,
   if (ELIMINATE_COPY_RELOCS
       && !get_elf_i386_backend_data (info->output_bfd)->is_vxworks)
     {
-      struct elf_i386_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
       eh = (struct elf_i386_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
        {
index a29ba8a324c3adbff9fe5969b7d09d88e9c7a65b..9fcf73a72f6a964e15febbbce697a30908e489d9 100644 (file)
@@ -2134,10 +2134,39 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
 {
   struct elf_x86_64_link_hash_table *htab;
   asection *s;
+  struct elf_x86_64_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
 
   /* STT_GNU_IFUNC symbol must go through PLT. */
   if (h->type == STT_GNU_IFUNC)
     {
+      /* Check local STT_GNU_IFUNC calls.  */
+      if (h->ref_regular
+         && SYMBOL_CALLS_LOCAL (info, h))
+       {
+         bfd_size_type pc_count = 0;
+         struct elf_dyn_relocs **pp;
+
+         eh = (struct elf_x86_64_link_hash_entry *) h;
+         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+           {
+             pc_count += p->pc_count;
+             p->count -= p->pc_count;
+             p->pc_count = 0;
+             if (p->count == 0)
+               *pp = p->next;
+             else
+               pp = &p->next;
+           }
+
+         if (pc_count)
+           {
+             h->needs_plt = 1;
+             h->plt.refcount += 1;
+             h->non_got_ref = 1;
+           }
+       }
+
       if (h->plt.refcount <= 0)
        {
          h->plt.offset = (bfd_vma) -1;
@@ -2214,9 +2243,6 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   if (ELIMINATE_COPY_RELOCS)
     {
-      struct elf_x86_64_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
       eh = (struct elf_x86_64_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
        {
index af699be7404e1f573d2ceb19a945005c2f450c2b..7e3bad506c1fde7c0087e4355a3846e01bed17a3 100644 (file)
@@ -1,3 +1,19 @@
+2012-12-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/14956
+       * ld-ifunc/ifunc-14-i386.d: Renamed to ...
+       * ld-ifunc/ifunc-14a-i386.d: This.
+
+       * ld-ifunc/ifunc-14-x86-64.d: Renamed to ...
+       * ld-ifunc/ifunc-14a-x86-64.d: This.
+
+       * ld-ifunc/ifunc-14b-i386.d: New file.
+       * ld-ifunc/ifunc-14b-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-14c-i386.d: Likewise.
+       * ld-ifunc/ifunc-14c-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-14d-i386.d: Likewise.
+       * ld-ifunc/ifunc-14d-x86-64.d: Likewise.
+
 2012-11-30  Roland McGrath  <mcgrathr@google.com>
 
        * ld-elf/ehdr_start.s: Put reference in .rodata section, not .data.
diff --git a/ld/testsuite/ld-ifunc/ifunc-14-i386.d b/ld/testsuite/ld-ifunc/ifunc-14-i386.d
deleted file mode 100644 (file)
index 0edc9fb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#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
deleted file mode 100644 (file)
index 2c4ebbb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#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\).*
-#...