diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2023-05-31 12:36:49 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2023-06-29 10:29:47 -0700 |
commit | 02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32 (patch) | |
tree | ce4597e2f5a7655696bba81191743e16d2ef1d5a /ld | |
parent | 96cc7918c18cdb7bd0331d836fa7f05341732580 (diff) | |
download | gdb-02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32.zip gdb-02c1ba6c94d4bb3f53dfeeb4401c8434c7834a32.tar.gz 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 'ld')
-rw-r--r-- | ld/ldlang.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index f4a8b72..b3a89bf 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -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; } |