This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/15107: Reference to GNU_UNIQUE symbol shouldn't create GNU_UNIQUE symbol
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Thu, 7 Feb 2013 10:03:56 -0800
- Subject: PATCH: PR ld/15107: Reference to GNU_UNIQUE symbol shouldn't create GNU_UNIQUE symbol
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
GNU_UNIQUE controls run-time lookup. We shouldn't set GNU_UNIQUE to
undefined symbol. This is consistent with gold. OK to install?
Thanks.
H.J.
---
bfd/
2013-02-07 H.J. Lu <hongjiu.lu@intel.com>
PR ld/15107
* elflink.c (elf_link_output_extsym): Set STB_GNU_UNIQUE only if
symbol is defined in regular object.
ld/testsuite/
2013-02-07 H.J. Lu <hongjiu.lu@intel.com>
PR ld/15107
* ld-unique/unique_empty.s: Add reference to "b".
diff --git a/bfd/elflink.c b/bfd/elflink.c
index d336730..e6c8351 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8868,7 +8868,8 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
/* Turn off visibility on local symbol. */
sym.st_other &= ~ELF_ST_VISIBILITY (-1);
}
- else if (h->unique_global)
+ /* Set STB_GNU_UNIQUE only if symbol is defined in regular object. */
+ else if (h->unique_global && h->def_regular)
sym.st_info = ELF_ST_INFO (STB_GNU_UNIQUE, h->type);
else if (h->root.type == bfd_link_hash_undefweak
|| h->root.type == bfd_link_hash_defweak)
diff --git a/ld/testsuite/ld-unique/unique_empty.s b/ld/testsuite/ld-unique/unique_empty.s
index efd6683..c4c52c2 100644
--- a/ld/testsuite/ld-unique/unique_empty.s
+++ b/ld/testsuite/ld-unique/unique_empty.s
@@ -1,4 +1,4 @@
.type main,"function"
.global main
main:
- .long 0
+ .dc.a b