summaryrefslogtreecommitdiff
path: root/ld/emultempl/pe.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-08-03 13:31:57 +0100
committerNick Clifton <nickc@redhat.com>2022-08-03 13:31:57 +0100
commita6ad7914429a22d3d835bd998b032212b776a08a (patch)
treed81caa6275932745dedefa9f17d391454a84a19f /ld/emultempl/pe.em
parent8b8da1a9f31941fa167c9f2bd2a80cdd1dccb452 (diff)
Fix a conflict between the linker's need to rename some PE format input libraries and the BFD library's file caching mechanism.
PR 29389 bfd * bfd.c (BFD_CLOSED_BY_CACHE): New bfd flag. * cache.c (bfd_cache_delete): Set BFD_CLOSED_BY_DELETE on the closed bfd. (bfd_cache_lookup_worker): Clear BFD_CLOSED_BY_DELETE on the newly reopened bfd. * opncls.c (bfd_set_filename): Refuse to change the name of a bfd that has been closed by bfd_cache_delete. Mark changed bfds as uncacheable. * bfd-in2.h: Regenerate. ld * ldlang.h (lang_input_statement_struct): Add sort_key field. * emultempl/pe.em (after_open): If multiple import libraries refer to the same bfd, store their names in the sort_key field. * emultempl/pep.em (after_open): Likewise. * ldlang.c (sort_filename): New function. Returns the filename to be used when sorting input files. (wild_sort): Use the sort_filename function.
Diffstat (limited to 'ld/emultempl/pe.em')
-rw-r--r--ld/emultempl/pe.em25
1 files changed, 14 insertions, 11 deletions
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 2fd4ff4aca..ad969ccec1 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -1583,6 +1583,7 @@ gld${EMULATION_NAME}_after_open (void)
{
struct bfd_symbol *s;
struct bfd_link_hash_entry * blhe;
+ bfd *other_bfd;
const char *other_bfd_filename;
s = (relocs[i]->sym_ptr_ptr)[0];
@@ -1599,20 +1600,25 @@ gld${EMULATION_NAME}_after_open (void)
|| blhe->type != bfd_link_hash_defined)
continue;
+ other_bfd = blhe->u.def.section->owner;
+ if (other_bfd->my_archive == is->the_bfd->my_archive)
+ continue;
+
other_bfd_filename
- = blhe->u.def.section->owner->my_archive
- ? bfd_get_filename (blhe->u.def.section->owner->my_archive)
- : bfd_get_filename (blhe->u.def.section->owner);
+ = (other_bfd->my_archive
+ ? bfd_get_filename (other_bfd->my_archive)
+ : bfd_get_filename (other_bfd));
if (filename_cmp (bfd_get_filename
(is->the_bfd->my_archive),
other_bfd_filename) == 0)
continue;
- /* Rename this implib to match the other one. */
- if (!bfd_set_filename (is->the_bfd->my_archive,
- other_bfd_filename))
- einfo ("%F%P: %pB: %E\n", is->the_bfd);
+ /* Sort this implib to match the other one. */
+ lang_input_statement_type *arch_is
+ = bfd_usrdata (is->the_bfd->my_archive);
+ arch_is->sort_key = other_bfd_filename;
+ break;
}
free (relocs);
@@ -1719,10 +1725,7 @@ gld${EMULATION_NAME}_after_open (void)
= xmalloc (strlen (bfd_get_filename (is->the_bfd)) + 3);
sprintf (new_name, "%s.%c",
bfd_get_filename (is->the_bfd), seq);
- is->filename = bfd_set_filename (is->the_bfd, new_name);
- free (new_name);
- if (!is->filename)
- einfo ("%F%P: %pB: %E\n", is->the_bfd);
+ is->sort_key = new_name;
}
}
}