[PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid()
Martin Storsjö
martin@martin.st
Tue Jan 4 20:21:53 GMT 2022
This makes the output deterministic without requiring the caller to
pass --temp-prefix.
This also avoids potential prefix clashes, if building multiple import
libraries that later are merged into one single import library (which
is done for a number of umbrella libraries in mingw-w64-crt).
Signed-off-by: Martin Storsjö <martin@martin.st>
---
binutils/dlltool.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 8c1ddd61f63..83f30676f77 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3930,9 +3930,6 @@ main (int ac, char **av)
}
}
- if (!tmp_prefix)
- tmp_prefix = prefix_encode ("d", getpid ());
-
for (i = 0; mtable[i].type; i++)
if (strcmp (mtable[i].type, mname) == 0)
break;
@@ -3992,6 +3989,22 @@ main (int ac, char **av)
optind++;
}
+ if (!tmp_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 ());
+ }
+ }
+
mangle_defs ();
if (exp_name)
--
2.25.1
More information about the Binutils
mailing list