aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/dlltool.c20
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/pe-dll.c32
4 files changed, 49 insertions, 17 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index ff25db2..8e31f14 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2022-01-11 Martin Storsjö <martin@martin.st>
+
+ * dlltool.c (main): If a prefix has not been provided, attempt to
+ use a deterministic one based upon the dll name.
+
2022-01-07 Pavel Mayorov <pmayorov@cloudlinux.com>
PR 28718
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 8c1ddd6..a1e2b48 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -348,7 +348,7 @@ typedef struct iheadt
static iheadtype *import_list = NULL;
static char *as_name = NULL;
static char * as_flags = "";
-static char *tmp_prefix;
+static char *tmp_prefix = NULL;
static int no_idata4;
static int no_idata5;
static char *exp_name;
@@ -3930,8 +3930,22 @@ main (int ac, char **av)
}
}
- if (!tmp_prefix)
- tmp_prefix = prefix_encode ("d", getpid ());
+ if (tmp_prefix == NULL)
+ {
+ /* If possible use a deterministic prefix. */
+ if (dll_name)
+ {
+ tmp_prefix = xmalloc (strlen (dll_name) + 2);
+ sprintf (tmp_prefix, "%s_", dll_name);
+ for (i = 0; tmp_prefix[i]; i++)
+ if (!ISALNUM (tmp_prefix[i]))
+ tmp_prefix[i] = '_';
+ }
+ else
+ {
+ tmp_prefix = prefix_encode ("d", getpid ());
+ }
+ }
for (i = 0; mtable[i].type; i++)
if (strcmp (mtable[i].type, mname) == 0)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 6083c99..441187d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-11 Martin Storsjö <martin@martin.st>
+
+ * pe-dll.c (make_head): Prefix the symbol name with the dll name.
+ (make_tail, make_one, make_singleton_name_thunk): Likewise.
+ (make_import_fixup_entry, make_runtime_pseudo_reloc): Likewise.
+ (pe_create_runtime_relocator_reference): Likewise.
+ (pe_dll_generate_implib): Set dll_symname_len.
+ (pe_process_import_defs): Likewise.
+
2021-12-16 Nick Clifton <nickc@redhat.com>
PR 28686
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 907fafc..95de94b 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -348,6 +348,7 @@ static const autofilter_entry_type autofilter_liblist[] =
{ STRING_COMMA_LEN ("libgcj") },
{ STRING_COMMA_LEN ("libmsvcrt") },
{ STRING_COMMA_LEN ("libmsvcrt-os") },
+ { STRING_COMMA_LEN ("libucrt") },
{ STRING_COMMA_LEN ("libucrtbase") },
{ NULL, 0 }
};
@@ -1972,6 +1973,7 @@ static int symptr;
static int tmp_seq;
static const char *dll_filename;
static char *dll_symname;
+static int dll_symname_len;
#define UNDSEC bfd_und_section_ptr
@@ -2082,8 +2084,8 @@ make_head (bfd *parent)
char *oname;
bfd *abfd;
- oname = xmalloc (20);
- sprintf (oname, "d%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2171,8 +2173,8 @@ make_tail (bfd *parent)
char *oname;
bfd *abfd;
- oname = xmalloc (20);
- sprintf (oname, "d%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2322,8 +2324,8 @@ make_one (def_file_export *exp, bfd *parent, bool include_jmp_stub)
}
}
- oname = xmalloc (20);
- sprintf (oname, "d%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_d%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2508,8 +2510,8 @@ make_singleton_name_thunk (const char *import, bfd *parent)
char *oname;
bfd *abfd;
- oname = xmalloc (20);
- sprintf (oname, "nmth%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_nmth%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2584,8 +2586,8 @@ make_import_fixup_entry (const char *name,
char *oname;
bfd *abfd;
- oname = xmalloc (20);
- sprintf (oname, "fu%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_fu%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2638,8 +2640,8 @@ make_runtime_pseudo_reloc (const char *name ATTRIBUTE_UNUSED,
bfd *abfd;
bfd_size_type size;
- oname = xmalloc (20);
- sprintf (oname, "rtr%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_rtr%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2725,8 +2727,8 @@ pe_create_runtime_relocator_reference (bfd *parent)
char *oname;
bfd *abfd;
- oname = xmalloc (20);
- sprintf (oname, "ertr%06d.o", tmp_seq);
+ oname = xmalloc (20 + dll_symname_len);
+ sprintf (oname, "%s_ertr%06d.o", dll_symname, tmp_seq);
tmp_seq++;
abfd = bfd_create (oname, parent);
@@ -2833,6 +2835,7 @@ pe_dll_generate_implib (def_file *def, const char *impfilename, struct bfd_link_
dll_filename = (def->name) ? def->name : dll_name;
dll_symname = xstrdup (dll_filename);
+ dll_symname_len = strlen (dll_symname);
for (i = 0; dll_symname[i]; i++)
if (!ISALNUM (dll_symname[i]))
dll_symname[i] = '_';
@@ -3201,6 +3204,7 @@ pe_process_import_defs (bfd *output_bfd, struct bfd_link_info *linfo)
dll_filename = module->name;
dll_symname = xstrdup (module->name);
+ dll_symname_len = strlen (dll_symname);
for (j = 0; dll_symname[j]; j++)
if (!ISALNUM (dll_symname[j]))
dll_symname[j] = '_';