[binutils-gdb] x86: Increment PLT count only for function symbols
H.J.Lu
hjl@sourceware.org
Wed Aug 23 20:14:00 GMT 2017
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b1bb697ea1259c0977c38f1ec5f2239cbe669869
commit b1bb697ea1259c0977c38f1ec5f2239cbe669869
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 23 13:12:04 2017 -0700
x86: Increment PLT count only for function symbols
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.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/elf32-i386.c | 5 +++--
bfd/elf64-x86-64.c | 5 +++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c7ce75d..db93894 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
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
extern_protected_data to FALSE if GNU_PROPERTY_NO_COPY_ON_PROTECTED
is set on any input relocatable file.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 1009c17..ae23752 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -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)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 244db80..3dc2c35 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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)
More information about the Binutils-cvs
mailing list