]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Increment PLT count only for function symbols
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 23 Aug 2017 20:12:04 +0000 (13:12 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 23 Aug 2017 20:12:04 +0000 (13:12 -0700)
Since PLT entry is needed only for function symbols, increment PLT count
only for function symbols.

* elf32-i386.c (elf_i386_check_relocs): Increment PLT count only
for function symbols.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c

index c7ce75d379be419ae6f332a8052b118654de1c12..db9389451120ddfe40199aa844180575939dbc0c 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_check_relocs): Increment PLT count only
+       for function symbols.
+       * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
 2017-08-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_link_setup_gnu_properties): Set
index 1009c17ff21c1c28caf8b7b14e272abfa68abf60..ae23752119c591ff534493f35992dcf61fda3201 100644 (file)
@@ -2273,8 +2273,9 @@ do_relocation:
              /* We may need a .plt entry if the symbol is a function
                 defined in a shared lib or is a STT_GNU_IFUNC function
                 referenced from the code or read-only section.  */
-             if (!h->def_regular
-                 || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
+             if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC)
+                 && (!h->def_regular
+                     || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0))
                h->plt.refcount += 1;
 
              if (r_type == R_386_PC32)
index 244db80ed61a56bac4036f74690af778289b7d2c..3dc2c356c48093c75c9fa5f588f1eb869a271cca 100644 (file)
@@ -2716,8 +2716,9 @@ pointer:
              /* We may need a .plt entry if the symbol is a function
                 defined in a shared lib or is a STT_GNU_IFUNC function
                 referenced from the code or read-only section.  */
-             if (!h->def_regular
-                 || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0)
+             if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC)
+                 && (!h->def_regular
+                     || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0))
                h->plt.refcount += 1;
 
              if (r_type == R_X86_64_PC32)