[PATCH] amend "ELF: give .note.GNU-stack proper section type"
H.J. Lu
hjl.tools@gmail.com
Thu Jan 15 22:56:15 GMT 2026
On Thu, Jan 15, 2026 at 8:27 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> From: H.J. Lu <hjl.tools@gmail.com>
>
> PR ld/33780
> Correct the section's special_sections[] entry as well, and further
> constrain ld's setting of the section type.
> ---
> Requires either the patch at the bottom of
> https://sourceware.org/pipermail/binutils/2026-January/147115.html
> or (afaict, didn't check myself)
> https://sourceware.org/pipermail/binutils/2026-January/147275.html
> as a prereq.
>
> I can't help the impression that the table entry in bfd/elf.c can in fact
> simply be deleted, as the subsequent one would now take care of all of the
> .note.* sections.
>
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -3139,7 +3139,7 @@ static const struct bfd_elf_special_sect
> static const struct bfd_elf_special_section special_sections_n[] =
> {
> { STRING_COMMA_LEN (".noinit"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
> - { STRING_COMMA_LEN (".note.GNU-stack"), 0, SHT_PROGBITS, 0 },
> + { STRING_COMMA_LEN (".note.GNU-stack"), 0, SHT_NOTE, 0 },
> { STRING_COMMA_LEN (".note"), -1, SHT_NOTE, 0 },
> { NULL, 0, 0, 0, 0 }
> };
> --- a/ld/ldelf.c
> +++ b/ld/ldelf.c
> @@ -1329,7 +1329,7 @@ ldelf_after_open (int use_libpath, int n
> flagword flags = SEC_READONLY | (link_info.execstack ? SEC_CODE : 0);
> s = bfd_make_section_with_flags (link_info.input_bfds,
> ".note.GNU-stack", flags);
> - if (s)
> + if (s && bfd_get_flavour (s->owner) == bfd_target_elf_flavour)
> elf_section_type (s) = SHT_NOTE;
> }
> return;
1. Please coordinate with GCC developers to change .note.GNU-stack to SHT_NOTE.
2. Please add a testcase to show why it should be changed to SHT_NOTE.
3. Please add a testcase for PR ld/33780.
--
H.J.
More information about the Binutils
mailing list