diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-04-20 07:48:24 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-04-20 07:48:35 -0700 |
commit | 59fa66c53823dc695f78669f40ec2eebab3aec42 (patch) | |
tree | 175d8e3b6761189c2a361c6cfdb4dce606d10c38 /bfd | |
parent | c76886885987e543f9162809ad86a0a37b394e82 (diff) | |
download | gdb-59fa66c53823dc695f78669f40ec2eebab3aec42.zip gdb-59fa66c53823dc695f78669f40ec2eebab3aec42.tar.gz gdb-59fa66c53823dc695f78669f40ec2eebab3aec42.tar.bz2 |
Handle symbol defined in IR and referenced in DSO
We need to make an IR symbol visible if it is defined in an IR object
and referenced in a dynamic object. When --as-needed is used, since
linker removes the IR symbol reference of the dynamic object if the
dynamic object isn't needed in the first pass, the IR definition isn't
visible to the dynamic object even if the dynamic object becomes needed
in the second pass. Add dynamic_ref_after_ir_def to bfd_link_hash_entry
to track IR symbol which is defined in an IR object and later referenced
in a dynamic object. dynamic_ref_after_ir_def is preserved when restoring
the symbol table for unneeded dynamic object.
bfd/
PR ld/21382
* elflink.c (elf_link_add_object_symbols): Preserve
dynamic_ref_after_ir_def when restoring the symbol table for
unneeded dynamic object.
include/
PR ld/21382
* bfdlink.h (bfd_link_hash_entry): Add dynamic_ref_after_ir_def.
ld/
PR ld/21382
* plugin.c (is_visible_from_outside): Symbol may be visible
from outside if dynamic_ref_after_ir_def is set.
(plugin_notice): Set dynamic_ref_after_ir_def if the symbol is
defined in an IR object and referenced in a dynamic object.
* testsuite/ld-plugin/lto.exp: Run PR ld/21382 tests.
* testsuite/ld-plugin/pr21382a.c: New file.
* testsuite/ld-plugin/pr21382b.c: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elflink.c | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 11fbdab..214d0a8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2017-04-20 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/21382 + * elflink.c (elf_link_add_object_symbols): Preserve + dynamic_ref_after_ir_def when restoring the symbol table for + unneeded dynamic object. + 2017-04-19 H.J. Lu <hongjiu.lu@intel.com> PR ld/21401 diff --git a/bfd/elflink.c b/bfd/elflink.c index 0add01b..972b6f8 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -4932,6 +4932,7 @@ error_free_dyn: struct elf_link_hash_entry *h; bfd_size_type size; unsigned int alignment_power; + unsigned int dynamic_ref_after_ir_def; for (p = htab->root.table.table[i]; p != NULL; p = p->next) { @@ -4953,6 +4954,10 @@ error_free_dyn: size = 0; alignment_power = 0; } + /* Preserve dynamic_ref_after_ir_def so that this symbol + will be exported when the dynamic lib becomes needed + in the second pass. */ + dynamic_ref_after_ir_def = h->root.dynamic_ref_after_ir_def; memcpy (p, old_ent, htab->root.table.entsize); old_ent = (char *) old_ent + htab->root.table.entsize; h = (struct elf_link_hash_entry *) p; @@ -4969,6 +4974,7 @@ error_free_dyn: if (alignment_power > h->root.u.c.p->alignment_power) h->root.u.c.p->alignment_power = alignment_power; } + h->root.dynamic_ref_after_ir_def = dynamic_ref_after_ir_def; } } |