forked from Imagelibrary/binutils-gdb
Implement -z dynamic-undefined-weak
-z nodynamic-undefined-weak is only implemented for x86. (The sparc backend has some support code but doesn't enable the option by including ld/emulparams/dynamic_undefined_weak.sh, and since the support looks like it may be broken I haven't enabled it.) This patch adds the complementary -z dynamic-undefined-weak, extends both options to affect building of shared libraries as well as executables, and adds support for the option on powerpc. include/ * bfdlink.h (struct bfd_link_info <dynamic_undefined_weak>): Revise comment. bfd/ * elflink.c (_bfd_elf_adjust_dynamic_symbol): Hide undefweak or make dynamic for info->dynamic_undefined_weak 0 and 1. * elf32-ppc.c:Formatting. (ensure_undefweak_dynamic): Don't make dynamic when info->dynamic_undefined_weak is zero. (allocate_dynrelocs): Discard undefweak dyn_relocs for info->dynamic_undefined_weak. Discard undef dyn_relocs when not default visibility. Discard undef and undefweak dyn_relocs earlier. (ppc_elf_relocate_section): Adjust to suit. * elf64-ppc.c: Formatting. (ensure_undefweak_dynamic): Don't make dynamic when info->dynamic_undefined_weak is zero. (allocate_dynrelocs): Discard undefweak dyn_relocs for info->dynamic_undefined_weak. Discard them earlier. ld/ * ld.texinfo (dynamic-undefined-weak): Document. (nodynamic-undefined-weak): Document that this option now can be used with shared libs. * emulparams/dynamic_undefined_weak.sh: Support -z dynamic-undefined-weak. * emulparams/elf32ppccommon.sh: Include dynamic_undefined_weak.sh. * testsuite/ld-undefined/weak-undef.exp (undef_weak_so), (undef_weak_exe): New. Use them. Add -z dynamic-undefined-weak and -z nodynamic-undefined-weak tests. * Makefile.am: Update powerpc dependencies. * Makefile.in: Regenerate.
This commit is contained in:
@@ -2803,6 +2803,24 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data)
|
||||
if (! _bfd_elf_fix_symbol_flags (h, eif))
|
||||
return FALSE;
|
||||
|
||||
if (h->root.type == bfd_link_hash_undefweak)
|
||||
{
|
||||
if (eif->info->dynamic_undefined_weak == 0)
|
||||
_bfd_elf_link_hash_hide_symbol (eif->info, h, TRUE);
|
||||
else if (eif->info->dynamic_undefined_weak > 0
|
||||
&& h->ref_regular
|
||||
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||
&& !bfd_hide_sym_by_version (eif->info->version_info,
|
||||
h->root.root.string))
|
||||
{
|
||||
if (!bfd_elf_link_record_dynamic_symbol (eif->info, h))
|
||||
{
|
||||
eif->failed = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If this symbol does not require a PLT entry, and it is not
|
||||
defined by a dynamic object, or is not referenced by a regular
|
||||
object, ignore it. We do have to handle a weak defined symbol,
|
||||
|
||||
Reference in New Issue
Block a user