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 /bfd | |
parent | 7bd787e8774f96712d2e15a4094f094e00ff45ba (diff) | |
download | gdb-b95a0a3177bcf797c8f5ad6a7d276fb6275352b7.zip gdb-b95a0a3177bcf797c8f5ad6a7d276fb6275352b7.tar.gz gdb-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 'bfd')
-rw-r--r-- | bfd/ChangeLog | 15 | ||||
-rw-r--r-- | bfd/cofflink.c | 3 | ||||
-rw-r--r-- | bfd/ecoff.c | 4 | ||||
-rw-r--r-- | bfd/elf64-ia64-vms.c | 2 | ||||
-rw-r--r-- | bfd/elflink.c | 2 | ||||
-rw-r--r-- | bfd/pdp11.c | 2 | ||||
-rw-r--r-- | bfd/vms-alpha.c | 2 | ||||
-rw-r--r-- | bfd/xcofflink.c | 4 |
8 files changed, 25 insertions, 9 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1be092b..f01cf1e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,18 @@ +2016-05-25 H.J. Lu <hongjiu.lu@intel.com> + + 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. + 2016-05-24 Maciej W. Rozycki <macro@imgtec.com> * elfxx-mips.c (_bfd_mips_elf_relocate_section) diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 4756fc3..b8a85b0 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -212,8 +212,9 @@ coff_link_check_archive_element (bfd *abfd, if (h->type != bfd_link_hash_undefined) return TRUE; + /* Include this element? */ if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd)) - return FALSE; + return TRUE; *pneeded = TRUE; return coff_link_add_object_symbols (abfd, info); diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 031abdf..d618572 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -3544,9 +3544,9 @@ ecoff_link_check_archive_element (bfd *abfd, if (h->type != bfd_link_hash_undefined) return TRUE; - /* Include this element. */ + /* Include this element? */ if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd)) - return FALSE; + return TRUE; *pneeded = TRUE; return ecoff_link_add_object_symbols (abfd, info); diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 760e1db..4482646 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -5361,7 +5361,7 @@ elf64_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) to include it. We don't need to check anything. */ if (! (*info->callbacks->add_archive_element) (info, element, h->root.string, &element)) - return FALSE; + continue; if (! elf64_vms_link_add_object_symbols (element, info)) return FALSE; diff --git a/bfd/elflink.c b/bfd/elflink.c index 1569e93..b4efd5a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -5283,7 +5283,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) if (!(*info->callbacks ->add_archive_element) (info, element, symdef->name, &element)) - goto error_return; + continue; if (!bfd_link_add_symbols (element, info)) goto error_return; diff --git a/bfd/pdp11.c b/bfd/pdp11.c index bf0cfc3..1f40be5 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -2608,7 +2608,7 @@ aout_link_check_ar_symbols (bfd *abfd, However, it might be correct. */ if (!(*info->callbacks ->add_archive_element) (info, abfd, name, subsbfd)) - return FALSE; + continue; *pneeded = TRUE; return TRUE; } diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index e6cfc1f..449354d 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -8202,7 +8202,7 @@ alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) to include it. We don't need to check anything. */ if (!(*info->callbacks ->add_archive_element) (info, element, h->root.string, &element)) - return FALSE; + continue; if (!alpha_vms_link_add_object_symbols (element, info)) return FALSE; diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index f6030f1..ca40096 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -2291,7 +2291,7 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd, { if (!(*info->callbacks ->add_archive_element) (info, abfd, name, subsbfd)) - return FALSE; + continue; *pneeded = TRUE; return TRUE; } @@ -2363,7 +2363,7 @@ xcoff_link_check_ar_symbols (bfd *abfd, { if (!(*info->callbacks ->add_archive_element) (info, abfd, name, subsbfd)) - return FALSE; + continue; *pneeded = TRUE; return TRUE; } |