]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR31208, strip can break ELF alignment requirements
authorAlan Modra <amodra@gmail.com>
Thu, 8 Feb 2024 20:34:22 +0000 (07:04 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 8 Feb 2024 20:53:08 +0000 (07:23 +1030)
In https://sourceware.org/pipermail/binutils/2007-August/053261.html
(git commit 3dea8fca8b86) I disabled a then new linker feature that
removed empty PT_LOAD headers in cases where a user specified program
headers, and for objcopy.  This can be a problem for objcopy/strip and
since objcopy operates on sections, any part of a PT_LOAD loading file
contents not covered by a section will be omitted anyway.

PR 31208
* elf.c (_bfd_elf_map_sections_to_segments): Pass remove_empty_load
as true to elf_modify_segment_map for objcopy/strip.

bfd/elf.c

index 88c75ae3ce046000dbcf4b918bad6758a550d435..8bffd3c514183711de5c638141f7aec1a9a0a4c0 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5789,7 +5789,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd,
       elf_seg_map (abfd) = mfirst;
     }
 
-  if (!elf_modify_segment_map (abfd, info, no_user_phdrs))
+  if (!elf_modify_segment_map (abfd, info, no_user_phdrs || info == NULL))
     return false;
 
   for (count = 0, m = elf_seg_map (abfd); m != NULL; m = m->next)