aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/pep.em
diff options
context:
space:
mode:
authorLuca Bacci <luca.bacci@outlook.com>2023-05-17 13:38:14 +0100
committerNick Clifton <nickc@redhat.com>2023-05-17 13:38:14 +0100
commit80d4e113d7b9af8a5a36e5ea4399bca86050784f (patch)
treea471fa8b0176805e795dd73a3a97b5af94630482 /ld/emultempl/pep.em
parent80b6c32f233ed28607643c4e4e4e2ee3399fdfd7 (diff)
downloadbinutils-80d4e113d7b9af8a5a36e5ea4399bca86050784f.zip
binutils-80d4e113d7b9af8a5a36e5ea4399bca86050784f.tar.gz
binutils-80d4e113d7b9af8a5a36e5ea4399bca86050784f.tar.bz2
Decorated symbols in import libs (BUG 30421)
PR 30421 * cofflink.c (_decoration_hash_newfunc): New function. (_bfd_coff_link_hash_table_init): Call it. * libcoff-in.h (struct coff_link_hash_table): Add decoration_hash field. (struct decoration_hash_entry): Declare. (_decoration_hash_newfunc): Prototype. * libcoff.h: Regenerate. * emultempl/pe.em (set_decoration): New function. (pe_fixup_stdcalls): Call the new function. * emultempl/pep.em (set_decoration): New function. (pep_fixup_stdcalls): Call the new function. * pe-dll.c (make_one): Check for decoated symbols.
Diffstat (limited to 'ld/emultempl/pep.em')
-rw-r--r--ld/emultempl/pep.em25
1 files changed, 25 insertions, 0 deletions
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 32883b2..99e7195 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -1120,6 +1120,30 @@ pep_undef_cdecl_match (struct bfd_link_hash_entry *h, void *inf)
}
static void
+set_decoration (const char *undecorated_name,
+ struct bfd_link_hash_entry * decoration)
+{
+ static bool gave_warning_message = false;
+ struct decoration_hash_entry *entry;
+
+ if (is_underscoring () && undecorated_name[0] == '_')
+ undecorated_name++;
+
+ entry = (struct decoration_hash_entry *)
+ bfd_hash_lookup (&(coff_hash_table (&link_info)->decoration_hash),
+ undecorated_name, true /* create */, false /* copy */);
+
+ if (entry->decorated_link != NULL && !gave_warning_message)
+ {
+ einfo (_("%P: warning: overwriting decorated name %s with %s\n"),
+ entry->decorated_link->root.string, undecorated_name);
+ gave_warning_message = true;
+ }
+
+ entry->decorated_link = decoration;
+}
+
+static void
pep_fixup_stdcalls (void)
{
static int gave_warning_message = 0;
@@ -1180,6 +1204,7 @@ pep_fixup_stdcalls (void)
undef->type = bfd_link_hash_defined;
undef->u.def.value = sym->u.def.value;
undef->u.def.section = sym->u.def.section;
+ set_decoration (undef->root.string, sym);
if (pep_enable_stdcall_fixup == -1)
{