This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed, PATCH] x86: Set GOT refcount to 1
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 10 Oct 2017 15:57:26 -0700
- Subject: [committed, PATCH] x86: Set GOT refcount to 1
- Authentication-results: sourceware.org; auth=none
Since x86 check_relocs is called after opening all inputs and garbage
collection, they never see the removed sections. There is no need
for incrementing GOT refcount. But since PLT refcount is also used in
/* Don't create the PLT entry if there are only function pointer
relocations which can be resolved at run-time. */
else if (htab->elf.dynamic_sections_created
&& (h->plt.refcount > eh->func_pointer_refcount
|| eh->plt_got.refcount > 0))
{
we must increment it.
* elf32-i386.c (elf_i386_check_relocs): Set GOT refcount to 1
instead of incrementing it.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
---
bfd/ChangeLog | 6 ++++++
bfd/elf32-i386.c | 6 +++---
bfd/elf64-x86-64.c | 6 +++---
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index bf400a9351..52ff647522 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (elf_i386_check_relocs): Set GOT refcount to 1
+ instead of incrementing it.
+ * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
2017-10-10 Renlin Li <renlin.li@arm.com>
PR ld/21402
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index f752de6063..ade1e7d9ce 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1603,7 +1603,7 @@ elf_i386_check_relocs (bfd *abfd,
switch (r_type)
{
case R_386_TLS_LDM:
- htab->tls_ld_or_ldm_got.refcount += 1;
+ htab->tls_ld_or_ldm_got.refcount = 1;
goto create_got;
case R_386_PLT32:
@@ -1670,7 +1670,7 @@ elf_i386_check_relocs (bfd *abfd,
if (h != NULL)
{
- h->got.refcount += 1;
+ h->got.refcount = 1;
old_tls_type = elf_x86_hash_entry (h)->tls_type;
}
else
@@ -1696,7 +1696,7 @@ elf_i386_check_relocs (bfd *abfd,
elf_x86_local_got_tls_type (abfd)
= (char *) (local_got_refcounts + 2 * symtab_hdr->sh_info);
}
- local_got_refcounts[r_symndx] += 1;
+ local_got_refcounts[r_symndx] = 1;
old_tls_type = elf_x86_local_got_tls_type (abfd) [r_symndx];
}
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 0b0aa6cb4d..7d65dca298 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1950,7 +1950,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
switch (r_type)
{
case R_X86_64_TLSLD:
- htab->tls_ld_or_ldm_got.refcount += 1;
+ htab->tls_ld_or_ldm_got.refcount = 1;
goto create_got;
case R_X86_64_TPOFF32:
@@ -1992,7 +1992,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (h != NULL)
{
- h->got.refcount += 1;
+ h->got.refcount = 1;
old_tls_type = eh->tls_type;
}
else
@@ -2018,7 +2018,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
elf_x86_local_got_tls_type (abfd)
= (char *) (local_got_refcounts + 2 * symtab_hdr->sh_info);
}
- local_got_refcounts[r_symndx] += 1;
+ local_got_refcounts[r_symndx] = 1;
old_tls_type
= elf_x86_local_got_tls_type (abfd) [r_symndx];
}
--
2.13.6