From: H.J. Lu Date: Wed, 23 Aug 2017 20:12:04 +0000 (-0700) Subject: x86: Increment PLT count only for function symbols X-Git-Tag: users/ARM/embedded-binutils-master-2017q4~1331 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1bb697ea1259c0977c38f1ec5f2239cbe669869;p=thirdparty%2Fbinutils-gdb.git 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 --git a/bfd/ChangeLog b/bfd/ChangeLog index c7ce75d379b..db938945112 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-08-23 H.J. Lu + + * 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 * elf32-i386.c (elf_i386_link_setup_gnu_properties): Set diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 1009c17ff21..ae23752119c 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 244db80ed61..3dc2c356c48 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)