diff options
Diffstat (limited to 'ld/emultempl/pe.em')
-rw-r--r-- | ld/emultempl/pe.em | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 1f2a5f310be..4fe0cf203fb 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1255,6 +1255,28 @@ make_import_fixup (arelent *rel, asection *s, char *name, const char *symname) pe_create_import_fixup (rel, s, _addend, name, symname); } +static void +make_runtime_ref (void) +{ + const char *rr = U ("_pei386_runtime_relocator"); + struct bfd_link_hash_entry *h + = bfd_wrapped_link_hash_lookup (link_info.output_bfd, &link_info, + rr, true, false, true); + if (!h) + einfo (_("%F%P: bfd_link_hash_lookup failed: %E\n")); + else + { + if (h->type == bfd_link_hash_new) + { + h->type = bfd_link_hash_undefined; + h->u.undef.abfd = NULL; + if (h->u.undef.next == NULL && h != link_info.hash->undefs_tail) + bfd_link_add_undef (link_info.hash, h); + } + h->non_ir_ref_regular = true; + } +} + static bool pr_sym (struct bfd_hash_entry *h, void *inf ATTRIBUTE_UNUSED) { @@ -1460,6 +1482,16 @@ setup_build_id (bfd *ibfd) } static void +gld${EMULATION_NAME}_before_plugin_all_symbols_read (void) +{ +#ifdef DLL_SUPPORT + if (link_info.lto_plugin_active + && link_info.pei386_auto_import) + make_runtime_ref (); +#endif +} + +static void gld${EMULATION_NAME}_after_open (void) { after_open_default (); @@ -2488,6 +2520,7 @@ EOF fi LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse +LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ=gld${EMULATION_NAME}_before_plugin_all_symbols_read LDEMUL_AFTER_OPEN=gld${EMULATION_NAME}_after_open LDEMUL_BEFORE_ALLOCATION=gld${EMULATION_NAME}_before_allocation LDEMUL_FINISH=gld${EMULATION_NAME}_finish |