diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-02-03 09:03:23 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-02-03 09:03:23 -0800 |
commit | 60f79275127603876d94da4bf4e3f6212903b407 (patch) | |
tree | 7aef6f3ba041e6588c0c354e7491bafff6ba7da8 /bfd/elflink.c | |
parent | 9910b1c8f3b0821944303fbcb4ef4c8872cf4e08 (diff) | |
download | gdb-60f79275127603876d94da4bf4e3f6212903b407.zip gdb-60f79275127603876d94da4bf4e3f6212903b407.tar.gz gdb-60f79275127603876d94da4bf4e3f6212903b407.tar.bz2 |
Mark the plugin symbol undefined
LTO may optimize out a plugin symbol, which is also referenced by a
non-IR file. When that happens, we should mark the plugin symbol
undefined. It isn't the problem since LTO already determined the
symbols in the non-IR file aren't used.
bfd/
PR ld/12365
PR ld/14272
* elflink.c (_bfd_elf_fix_symbol_flags): Mark the plugin symbol
undefined if it is referenced from a non-IR file.
ld/testsuite/
PR ld/12365
* ld-plugin/pr12365a.c: New file.
* ld-plugin/pr12365b.c: Likewise.
* ld-plugin/pr12365c.c: Likewise.
* ld-plugin/lto.exp (lto_link_tests): Prepare for the PR ld/12365
test.
Run the PR ld/12365 test.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 26af870..604cfb6 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2423,6 +2423,20 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, } else { + /* If a plugin symbol is referenced from a non-IR file, mark + the symbol as undefined, except for symbol for linker + created section. */ + if (h->root.non_ir_ref + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && (h->root.u.def.section->flags & SEC_LINKER_CREATED) == 0 + && h->root.u.def.section->owner != NULL + && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0) + { + h->root.type = bfd_link_hash_undefined; + h->root.u.undef.abfd = h->root.u.def.section->owner; + } + /* Unfortunately, NON_ELF is only correct if the symbol was first seen in a non-ELF file. Fortunately, if the symbol was first seen in an ELF file, we're probably OK unless the |