This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] bfd: Mark symbols with mismatching types
- From: Egeyar Bagcioglu <egeyar dot bagcioglu at oracle dot com>
- To: binutils at sourceware dot org
- Date: Wed, 12 Apr 2017 22:11:42 -0700
- Subject: [PATCH] bfd: Mark symbols with mismatching types
- Authentication-results: sourceware.org; auth=none
Introduce flag for defined symbols whose type is mismatched with a
dynamic definition. Mark such symbols. Prevent such symbols from being
made dynamic in sparc.
Sparc makes use of dynamic symbols during relocations. Unless detected,
above-mentioned symbols are confused with library symbols by the dynamic
linker.
This change is tested for sparc64-unknown-linux-gnu.
bfd/ChangeLog:
2017-04-11 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com>
* elf-bfd.h (elf_link_hash_entry): Add conflict_with_library.
* elflink.c (_bfd_elf_merge_symbol): Set conflict_with_library.
* elfxx-sparc.c (allocate_dynrelocs): Avoid the call to
bfd_elf_link_record_dynamic_symbol in case of conflict_with_library.
---
bfd/elf-bfd.h | 2 ++
bfd/elflink.c | 1 +
bfd/elfxx-sparc.c | 6 ++++--
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index af377ee..150f038 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -213,6 +213,8 @@ struct elf_link_hash_entry
/* Symbol is defined by a shared library with non-default visibility
in a read/write section. */
unsigned int protected_def : 1;
+ /* Symbol is defined also with a different type in a shared library */
+ unsigned int conflict_with_library : 1;
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index c00d712..7a9979a 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1257,6 +1257,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
&& h->type != STT_NOTYPE
&& !(newfunc && oldfunc))
{
+ h->conflict_with_library = 1;
*skip = TRUE;
return TRUE;
}
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index c978aad..c4e7b7c 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -2310,7 +2310,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
Undefined weak syms won't yet be marked as dynamic. */
if (h->dynindx == -1
&& !h->forced_local
- && !resolved_to_zero)
+ && !resolved_to_zero
+ && !h->conflict_with_library)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
@@ -2422,7 +2423,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
Undefined weak syms won't yet be marked as dynamic. */
if (h->dynindx == -1
&& !h->forced_local
- && !resolved_to_zero)
+ && !resolved_to_zero
+ && !h->conflict_with_library)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
return FALSE;
--
1.7.1