diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-06-20 05:10:29 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-06-20 05:10:46 -0700 |
commit | 7dc3990e4002e0062007c1d41b56e04b5b8ec1ec (patch) | |
tree | 4e2190341e363ae4dac71d031c109ffd265aba04 /bfd/elflink.c | |
parent | 9f99c22eb74a66e691b778cd15c24437f46d5818 (diff) | |
download | gdb-7dc3990e4002e0062007c1d41b56e04b5b8ec1ec.zip gdb-7dc3990e4002e0062007c1d41b56e04b5b8ec1ec.tar.gz gdb-7dc3990e4002e0062007c1d41b56e04b5b8ec1ec.tar.bz2 |
Use the IR symbol table for the IR input object
ELF linker shouldn't skip the IR object when searching the symbol table
of an archive element. If linker doesn't know if the object file is an
IR object, it should give LTO plugin a chance to get the correct symbol
table and use the IR symbol table if the input is an IR object.
bfd/
PR ld/18250
PR ld/20267
* elflink.c: Include plugin.h if BFD_SUPPORTS_PLUGINS is
defined.
(elf_link_is_defined_archive_symbol): Call
bfd_link_plugin_object_p on unknown plugin object and use the
IR symbol table if the input is an IR object.
* plugin.c (bfd_link_plugin_object_p): New function.
* plugin.h (bfd_link_plugin_object_p): New prototype.
ld/
PR ld/20267
* testsuite/ld-plugin/lto.exp (lto_link_tests): Add test for
PR ld/20267.
(lto_run_tests): Likewise.
* testsuite/ld-plugin/pr20267a.c: New file.
* testsuite/ld-plugin/pr20267b.c: Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index d4e8db6..bb83854 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -28,6 +28,9 @@ #include "safe-ctype.h" #include "libiberty.h" #include "objalloc.h" +#ifdef BFD_SUPPORTS_PLUGINS +#include "plugin.h" +#endif /* This struct is used to pass information to routines called via elf_link_hash_traverse which must return failure. */ @@ -3124,15 +3127,25 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) if (abfd == NULL) return FALSE; - /* Return FALSE if the object has been claimed by plugin. */ - if (abfd->plugin_format == bfd_plugin_yes) - return FALSE; - if (! bfd_check_format (abfd, bfd_object)) return FALSE; - /* Select the appropriate symbol table. */ - if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) + /* Select the appropriate symbol table. If we don't know if the + object file is an IR object, give linker LTO plugin a chance to + get the correct symbol table. */ + if (abfd->plugin_format == bfd_plugin_yes +#ifdef BFD_SUPPORTS_PLUGINS + || (abfd->plugin_format == bfd_plugin_unknown + && bfd_link_plugin_object_p (abfd)) +#endif + ) + { + /* Use the IR symbol table if the object has been claimed by + plugin. */ + abfd = abfd->plugin_dummy_bfd; + hdr = &elf_tdata (abfd)->symtab_hdr; + } + else if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) hdr = &elf_tdata (abfd)->symtab_hdr; else hdr = &elf_tdata (abfd)->dynsymtab_hdr; |