]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/ldlang.c
2.41 Release sources
[thirdparty/binutils-gdb.git] / ld / ldlang.c
index f4a8b72869eb7a803962bc72da0e5433d6a369f5..a357f80235f49f01f45f774b5cc4047e61bb1622 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,
@@ -2538,6 +2544,10 @@ lang_discard_section_p (asection *section)
       && (flags & SEC_DEBUGGING) != 0)
     discard = true;
 
+  /* Discard non-alloc sections if we are stripping section headers.  */
+  else if (config.no_section_header && (flags & SEC_ALLOC) == 0)
+    discard = true;
+
   return discard;
 }