- pe_create_import_fixup (rel, s, bfd_get_32 (s->owner, addend), name);
-
- return 1;
-}
-
-static void
-pe_find_data_imports (void)
-{
- struct bfd_link_hash_entry *undef, *sym;
- size_t namelen;
- char *buf, *name;
-
- if (link_info.pei386_auto_import == 0)
- return;
-
- namelen = 0;
- for (undef = link_info.hash->undefs; undef; undef = undef->u.undef.next)
- {
- if (undef->type == bfd_link_hash_undefined)
- {
- size_t len = strlen (undef->root.string);
- if (namelen < len)
- namelen = len;
- }
- }
- if (namelen == 0)
- return;
-
- /* We are being a bit cunning here. The buffer will have space for
- prefixes at the beginning. The prefix is modified here and in a
- number of functions called from this function. */
-#define PREFIX_LEN 32
- buf = xmalloc (PREFIX_LEN + namelen + 1);
- name = buf + PREFIX_LEN;
-
- for (undef = link_info.hash->undefs; undef; undef = undef->u.undef.next)
- {
- if (undef->type == bfd_link_hash_undefined)
- {
- char *impname;
-
- if (pe_dll_extra_pe_debug)
- printf ("%s:%s\n", __FUNCTION__, undef->root.string);
-
- strcpy (name, undef->root.string);
- impname = name - (sizeof "__imp_" - 1);
- memcpy (impname, "__imp_", sizeof "__imp_" - 1);
-
- sym = bfd_link_hash_lookup (link_info.hash, impname, 0, 0, 1);
-
- if (sym && sym->type == bfd_link_hash_defined)
- {
- bfd *b = sym->u.def.section->owner;
- asymbol **symbols;
- int nsyms, i;
-
- if (link_info.pei386_auto_import == -1)
- {
- static bfd_boolean warned = FALSE;
-
- info_msg (_("Info: resolving %s by linking to %s "
- "(auto-import)\n"), name, impname);
-
- /* PR linker/4844. */
- if (! warned)
- {
- warned = TRUE;
- einfo (_("%P: warning: auto-importing has been activated "
- "without --enable-auto-import specified on the "
- "command line; this should work unless it "
- "involves constant data structures referencing "
- "symbols from auto-imported DLLs\n"));
- }
- }
-
- if (!bfd_generic_link_read_symbols (b))
- {
- einfo (_("%F%P: %pB: could not read symbols: %E\n"), b);
- return;
- }
-
- symbols = bfd_get_outsymbols (b);
- nsyms = bfd_get_symcount (b);
-
- for (i = 0; i < nsyms; i++)
- {
- if (! CONST_STRNEQ (symbols[i]->name, U ("_head_")))
- continue;
-
- if (pe_dll_extra_pe_debug)
- printf ("->%s\n", symbols[i]->name);
-
- pe_data_import_dll = (char *) (symbols[i]->name
- + U_SIZE ("_head_") - 1);
- break;
- }
-
- pe_walk_relocs_of_symbol (&link_info, name, make_import_fixup);
-
- /* Let's differentiate it somehow from defined. */
- undef->type = bfd_link_hash_defweak;
- /* We replace original name with __imp_ prefixed, this
- 1) may trash memory 2) leads to duplicate symbol generation.
- Still, IMHO it's better than having name polluted. */
- undef->root.string = sym->root.string;
- undef->u.def.value = sym->u.def.value;
- undef->u.def.section = sym->u.def.section;
- }
- }
- }
- free (buf);