aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2023-05-31 12:36:49 -0700
committerH.J. Lu <hjl.tools@gmail.com>2023-06-29 10:29:47 -0700
commit02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32 (patch)
treece4597e2f5a7655696bba81191743e16d2ef1d5a /binutils
parent96cc7918c18cdb7bd0331d836fa7f05341732580 (diff)
downloadfsf-binutils-gdb-02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32.zip
fsf-binutils-gdb-02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32.tar.gz
fsf-binutils-gdb-02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32.tar.bz2
ELF: Discard non-alloc sections without section header
Discard non-alloc sections when section headers are stripped. bfd/ PR ld/25617 * elf.c (_bfd_elf_assign_file_positions_for_non_load): Skip non-load sections without section header. (_bfd_elf_write_object_contents): Don't set the sh_name field without section header. Write out the .shstrtab section only if its sh_offset field isn't -1. binutils/ PR ld/25617 * objcopy.c (is_strip_section_1): Remove non-alloc sections for --strip-section-headers. ld/ PR ld/25617 * ldlang.c (lang_discard_section_p): Discard non-alloc sections if we are stripping section headers.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/objcopy.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 206d80b..3569b89 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1377,6 +1377,11 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
return true;
}
+ /* Remove non-alloc sections for --strip-section-headers. */
+ if (strip_section_headers
+ && (bfd_section_flags (sec) & SEC_ALLOC) == 0)
+ return true;
+
if ((bfd_section_flags (sec) & SEC_DEBUGGING) != 0)
{
if (strip_symbols == STRIP_DEBUG
@@ -2730,7 +2735,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
if (strip_section_headers)
{
- non_fatal (_("--strip_section_headers is unsupported on `%s'"),
+ non_fatal (_("--strip-section-headers is unsupported on `%s'"),
bfd_get_archive_filename (ibfd));
return false;
}