dlltool: Allow inferring tmp_prefix from the dll name from a def file

Message ID 20220111203654.1577650-1-martin@martin.st
State New
Headers show
Series
  • dlltool: Allow inferring tmp_prefix from the dll name from a def file
Related show

Commit Message

Martin Storsjö Jan. 11, 2022, 8:36 p.m.
Move the initialization of tmp_prefix slightly later in the process,
which should allow inferring a deterministic tmp_prefix from the
dll name read from a def file, not only from the -D option.

Signed-off-by: Martin Storsjö <martin@martin.st>

---
 binutils/dlltool.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

-- 
2.25.1

Patch

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index a1e2b484328..d95bf3f5470 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -3930,23 +3930,6 @@  main (int ac, char **av)
 	}
     }
 
-  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)
       break;
@@ -4006,6 +3989,23 @@  main (int ac, char **av)
       optind++;
     }
 
+  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 ());
+        }
+    }
+
   mangle_defs ();
 
   if (exp_name)