diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-05-25 08:40:52 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-05-25 08:41:05 -0700 |
commit | b95a0a3177bcf797c8f5ad6a7d276fb6275352b7 (patch) | |
tree | e117a53aa091141f8779f85e94d718ab44da2e04 /ld/ldmain.c | |
parent | 7bd787e8774f96712d2e15a4094f094e00ff45ba (diff) | |
download | binutils-b95a0a3177bcf797c8f5ad6a7d276fb6275352b7.zip binutils-b95a0a3177bcf797c8f5ad6a7d276fb6275352b7.tar.gz binutils-b95a0a3177bcf797c8f5ad6a7d276fb6275352b7.tar.bz2 |
Skip an archive element if not added by linker
During archive rescan to resolve symbol references for files added by
LTO, linker add_archive_element callback is called to check if an
archive element should added. After all IR symbols have been claimed,
linker won't claim new IR symbols and shouldn't add the LTO archive
element. This patch updates linker add_archive_element callback to
return FALSE when seeing an LTO archive element during rescan and
changes ELF linker to skip such archive element.
bfd/
PR ld/20103
* cofflink.c (coff_link_check_archive_element): Return TRUE if
linker add_archive_element callback returns FALSE.
* ecoff.c (ecoff_link_check_archive_element): Likewise.
* elf64-ia64-vms.c (elf64_vms_link_add_archive_symbols): Skip
archive element if linker add_archive_element callback returns
FALSE.
* elflink.c (elf_link_add_archive_symbols): Likewise.
* pdp11.c (aout_link_check_ar_symbols): Likewise.
* vms-alpha.c (alpha_vms_link_add_archive_symbols): Likewise.
* xcofflink.c (xcoff_link_check_dynamic_ar_symbols): Likewise.
(xcoff_link_check_ar_symbols): Likewise.
ld/
PR ld/20103
* ldmain.c (add_archive_element): Don't claim new IR symbols
after all IR symbols have been claimed.
* plugin.c (plugin_call_claim_file): Remove no_more_claiming
check.
* testsuite/ld-plugin/lto.exp (pr20103): New proc.
Run PR ld/20103 tests.
* testsuite/ld-plugin/pr20103a.c: New file.
* testsuite/ld-plugin/pr20103b.c: Likewise.
* testsuite/ld-plugin/pr20103c.c: Likewise.
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index 21133ab..7d04be2 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -796,12 +796,22 @@ add_archive_element (struct bfd_link_info *info, BFD, but we still want to output the original BFD filename. */ orig_input = *input; #ifdef ENABLE_PLUGINS - if (link_info.lto_plugin_active && !no_more_claiming) + if (link_info.lto_plugin_active) { /* We must offer this archive member to the plugins to claim. */ plugin_maybe_claim (input); if (input->flags.claimed) { + if (no_more_claiming) + { + /* Don't claim new IR symbols after all IR symbols have + been claimed. */ + if (trace_files || verbose) + info_msg ("%I: no new IR symbols to claimi\n", + &orig_input); + input->flags.claimed = 0; + return FALSE; + } input->flags.claim_archive = TRUE; *subsbfd = input->the_bfd; } |