aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2000-07-28 00:49:07 +0000
committerH.J. Lu <hjl.tools@gmail.com>2000-07-28 00:49:07 +0000
commit456981d71502f17f86b9b3a7fbcef5cec3abcb5d (patch)
tree286006f5f5d09d43d17b2e5dd5515381d9491733 /bfd/elflink.h
parentc6a7ab1f7547c0ffc316df5e6611b47f2fda4bb5 (diff)
downloadgdb-456981d71502f17f86b9b3a7fbcef5cec3abcb5d.zip
gdb-456981d71502f17f86b9b3a7fbcef5cec3abcb5d.tar.gz
gdb-456981d71502f17f86b9b3a7fbcef5cec3abcb5d.tar.bz2
2000-07-27 H.J. Lu <hjl@gnu.org>
* 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 ().
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r--bfd/elflink.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h
index 6b91d31..1dadc49 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)