From 456981d71502f17f86b9b3a7fbcef5cec3abcb5d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 28 Jul 2000 00:49:07 +0000 Subject: [PATCH] 2000-07-27 H.J. Lu * elflink.h (elf_merge_symbol): Take one more argument, dt_needed, to indicate if the symbol comes from a DT_NEEDED entry. Don't overide the existing weak definition if dt_needed is true. (elf_link_add_object_symbols): Pass dt_needed to elf_merge_symbol (). --- bfd/ChangeLog | 9 +++++++++ bfd/elflink.h | 34 +++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5e4dd249add..3a71ac53493 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2000-07-27 H.J. Lu + + * elflink.h (elf_merge_symbol): Take one more argument, + dt_needed, to indicate if the symbol comes from a DT_NEEDED + entry. Don't overide the existing weak definition if dt_needed + is true. + (elf_link_add_object_symbols): Pass dt_needed to + elf_merge_symbol (). + 2000-07-27 Nick Clifton * elflink.h (elf_link_size_reloc_section): Zeroes the section's diff --git a/bfd/elflink.h b/bfd/elflink.h index 6b91d3135e0..1dadc49c4c6 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -35,7 +35,7 @@ static boolean elf_link_add_archive_symbols static boolean elf_merge_symbol PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection **, bfd_vma *, struct elf_link_hash_entry **, - boolean *, boolean *, boolean *)); + boolean *, boolean *, boolean *, boolean)); static boolean elf_export_symbol PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_fix_symbol_flags @@ -433,11 +433,12 @@ elf_link_add_archive_symbols (abfd, info) TYPE_CHANGE_OK if it is OK for the type to change. We set SIZE_CHANGE_OK if it is OK for the size to change. By OK to change, we mean that we shouldn't warn if the type or size does - change. */ + change. DT_NEEDED indicates if it comes from a DT_NEEDED entry of + a shared object. */ static boolean elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, - override, type_change_ok, size_change_ok) + override, type_change_ok, size_change_ok, dt_needed) bfd *abfd; struct bfd_link_info *info; const char *name; @@ -448,6 +449,7 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, boolean *override; boolean *type_change_ok; boolean *size_change_ok; + boolean dt_needed; { asection *sec; struct elf_link_hash_entry *h; @@ -624,9 +626,11 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, olddyncommon = false; /* It's OK to change the type if either the existing symbol or the - new symbol is weak. */ + new symbol is weak unless it comes from a DT_NEEDED entry of + a shared object, in which case, the DT_NEEDED entry may not be + required at the run time. */ - if (h->root.type == bfd_link_hash_defweak + if ((! dt_needed && h->root.type == bfd_link_hash_defweak) || h->root.type == bfd_link_hash_undefweak || bind == STB_WEAK) *type_change_ok = true; @@ -678,7 +682,9 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, object to override a weak symbol in a shared object. We prefer a non-weak definition in a shared library to a weak - definition in the executable. */ + definition in the executable unless it comes from a DT_NEEDED + entry of a shared object, in which case, the DT_NEEDED entry + may not be required at the run time. */ if (newdyn && newdef @@ -686,7 +692,8 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, || (h->root.type == bfd_link_hash_common && (bind == STB_WEAK || ELF_ST_TYPE (sym->st_info) == STT_FUNC))) - && (h->root.type != bfd_link_hash_defweak + && (h->root.type != bfd_link_hash_defweak + || dt_needed || bind == STB_WEAK)) { *override = true; @@ -821,8 +828,11 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, /* Handle the special case of a weak definition in a regular object followed by a non-weak definition in a shared object. In this - case, we prefer the definition in the shared object. */ + case, we prefer the definition in the shared object unless it + comes from a DT_NEEDED entry of a shared object, in which case, + the DT_NEEDED entry may not be required at the run time. */ if (olddef + && ! dt_needed && h->root.type == bfd_link_hash_defweak && newdef && newdyn @@ -1465,7 +1475,7 @@ elf_link_add_object_symbols (abfd, info) if (! elf_merge_symbol (abfd, info, name, &sym, &sec, &value, sym_hash, &override, &type_change_ok, - &size_change_ok)) + &size_change_ok, dt_needed)) goto error_return; if (override) @@ -1668,7 +1678,8 @@ elf_link_add_object_symbols (abfd, info) size_change_ok = false; if (! elf_merge_symbol (abfd, info, shortname, &sym, &sec, &value, &hi, &override, - &type_change_ok, &size_change_ok)) + &type_change_ok, + &size_change_ok, dt_needed)) goto error_return; if (! override) @@ -1785,7 +1796,8 @@ elf_link_add_object_symbols (abfd, info) size_change_ok = false; if (! elf_merge_symbol (abfd, info, shortname, &sym, &sec, &value, &hi, &override, - &type_change_ok, &size_change_ok)) + &type_change_ok, + &size_change_ok, dt_needed)) goto error_return; if (override) -- 2.30.2