From 4596421b6715cf00d2630e4b3d8372278b42d7d1 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sun, 11 Aug 1996 03:39:46 +0000 Subject: [PATCH] * elflink.h (elf_link_add_object_symbols): Do not resolve a common symbol against a STT_FUNC symbol in a shared library. --- bfd/ChangeLog | 5 +++++ bfd/elflink.h | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b185f7d439e..c0cc3161edc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +Sat Aug 10 22:59:17 1996 Ian Lance Taylor + + * elflink.h (elf_link_add_object_symbols): Do not resolve a common + symbol against a STT_FUNC symbol in a shared library. + Fri Aug 9 12:44:57 1996 Ian Lance Taylor * xcofflink.c (xcoff_link_add_dynamic_symbols): If a descriptor diff --git a/bfd/elflink.h b/bfd/elflink.h index 04ef289a9df..27398a4c6dc 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -679,17 +679,25 @@ elf_link_add_object_symbols (abfd, info) by some other object. If it has, we want to use the existing definition, and we do not want to report a multiple symbol definition error; we do this by - clobbering sec to be bfd_und_section_ptr. */ + clobbering sec to be bfd_und_section_ptr. We treat a + common symbol as a definition if the symbol in the shared + library is a function, since common symbols always + represent variables; this can cause confusion in + principle, but any such confusion would seem to indicate + an erroneous program or shared library. */ if (dynamic && definition) { if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak || (h->root.type == bfd_link_hash_common - && bind == STB_WEAK)) + && (bind == STB_WEAK + || ELF_ST_TYPE (sym.st_info) == STT_FUNC))) { sec = bfd_und_section_ptr; definition = false; size_change_ok = true; + if (h->root.type == bfd_link_hash_common) + type_change_ok = true; } } @@ -700,7 +708,10 @@ elf_link_add_object_symbols (abfd, info) objects, even if they are defined after the dynamic object in the link. */ if (! dynamic - && definition + && (definition + || (bfd_is_com_section (sec) + && (h->root.type == bfd_link_hash_defweak + || h->type == STT_FUNC))) && (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 @@ -715,6 +726,8 @@ elf_link_add_object_symbols (abfd, info) h->root.type = bfd_link_hash_undefined; h->root.u.undef.abfd = h->root.u.def.section->owner; size_change_ok = true; + if (bfd_is_com_section (sec)) + type_change_ok = true; } } -- 2.30.2