]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR 30632 - ld segfaults if linker script includes a STARTUP line.
authorPter Chubb <peter.chubb@unsw.edu.au>
Tue, 18 Jul 2023 16:04:43 +0000 (17:04 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 18 Jul 2023 16:04:43 +0000 (17:04 +0100)
ld/ldlang.c

index 4b86c1648433e92a7c977b7d8984b0f32511b0ea..f7760fed69bf2cf28d853f763bf976ffb54a9c02 100644 (file)
@@ -1136,9 +1136,15 @@ new_afile (const char *name,
 
   lang_has_input_file = true;
 
-  name = ldfile_possibly_remap_input (name);
-  if (name == NULL)
-    return NULL;
+  /* PR 30632: It is OK for name to be NULL.  For example
+     see the initialization of first_file in lang_init().  */
+  if (name != NULL)
+    {
+      name = ldfile_possibly_remap_input (name);
+      /* But if a name is remapped to NULL, it should be ignored.  */
+      if (name == NULL)
+       return NULL;
+    }
 
   p = new_stat (lang_input_statement, stat_ptr);
   memset (&p->the_bfd, 0,