[binutils-gdb] amend "ELF: give .note.GNU-stack proper section type"
Jan Beulich
jbeulich@sourceware.org
Wed Jan 21 13:48:29 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bc6e40a093e700e84b549902d55e73bfe92a113b
commit bc6e40a093e700e84b549902d55e73bfe92a113b
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jan 21 14:43:06 2026 +0100
amend "ELF: give .note.GNU-stack proper section type"
PR ld/33780
Correct the section's special_sections[] entry as well, and further
constrain ld's setting of the section type.
Diff:
---
bfd/elf.c | 2 +-
ld/ldelf.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index 1177c3c3016..75a2e0b9358 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3139,7 +3139,7 @@ static const struct bfd_elf_special_section special_sections_l[] =
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 }
};
diff --git a/ld/ldelf.c b/ld/ldelf.c
index fe4ab17b01f..a3f892a1934 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1329,7 +1329,7 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
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;
More information about the Binutils-cvs
mailing list