]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/ldlang.c
ELF: Discard non-alloc sections without section header
[thirdparty/binutils-gdb.git] / ld / ldlang.c
index f4a8b72869eb7a803962bc72da0e5433d6a369f5..b3a89bf041b651bf335ee34e9b782f92fabf27f0 100644 (file)
@@ -2538,6 +2538,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;
 }