commit: a04d7009f98cffdaf2a348ca91896495a676a8b2 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Tue Jan 20 05:27:33 2026 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Jan 20 05:27:43 2026 +0000 URL: https://gitweb.gentoo.org/proj/toolchain/binutils-patches.git/commit/?id=a04d7009
Revert "9999: try Jan's patches too" This reverts commit 093307e8692feea611157b9aa3d43d0835f51bdf. https://sourceware.org/bugzilla/show_bug.cgi?id=33780#c12 Signed-off-by: Sam James <sam <AT> gentoo.org> 9999/0006-GNU-stack.patch | 62 ------- ...-give-.note.GNU-stack-proper-section-type.patch | 178 +++++++++++++++++++++ 2 files changed, 178 insertions(+), 62 deletions(-) diff --git a/9999/0006-GNU-stack.patch b/9999/0006-GNU-stack.patch deleted file mode 100644 index bdd2abc..0000000 --- a/9999/0006-GNU-stack.patch +++ /dev/null @@ -1,62 +0,0 @@ -https://sourceware.org/bugzilla/show_bug.cgi?id=33780#c10 -https://inbox.sourceware.org/binutils/[email protected]/ -https://inbox.sourceware.org/binutils/[email protected]/ ---- a/binutils/readelf.c -+++ b/binutils/readelf.c -@@ -23802,8 +23802,8 @@ process_notes_at (Filedata * f - char *end; - bool res = true; - -- if (length <= 0) -- return false; -+ if (length == 0) -+ return true; - - if (section) - { - -From 49c09f0770364570c37c2ad76e37754506e397d8 Mon Sep 17 00:00:00 2001 -Message-ID: <49c09f0770364570c37c2ad76e37754506e397d8.1768782380.git....@gentoo.org> -From: "H.J. Lu" <[email protected]> -Date: Thu, 15 Jan 2026 13:27:25 +0100 -Subject: [PATCH] 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. ---- - 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; - -base-commit: c9c234a8a86cbbad03e92bc04f91b612e7f915e2 --- -2.52.0 - diff --git a/9999/0006-Revert-ELF-give-.note.GNU-stack-proper-section-type.patch b/9999/0006-Revert-ELF-give-.note.GNU-stack-proper-section-type.patch new file mode 100644 index 0000000..c8a625d --- /dev/null +++ b/9999/0006-Revert-ELF-give-.note.GNU-stack-proper-section-type.patch @@ -0,0 +1,178 @@ +From bd003d6e4b53b846fa8e576e050aee473bd4054d Mon Sep 17 00:00:00 2001 +Message-ID: <bd003d6e4b53b846fa8e576e050aee473bd4054d.1768126718.git....@gentoo.org> +From: "H.J. Lu" <[email protected]> +Date: Sat, 10 Jan 2026 11:41:48 +0800 +Subject: [PATCH] elf: Don't set .note.GNU-stack type to SHT_NOTE + +.note.GNU-stack section was introduced with the SHT_PROGBITS type. +Although its name starts with ".note.", but it doesn't conform to +SHT_NOTE specification: + +https://gabi.xinuos.com/v42/elf/07-pheader.html#note-sections + +since it is an empty section without the corresponding SHT_NOTE section +fields and maps to PT_GNU_STACK segment, not PT_NOTE segment. Linkers +normally check section types when laying out the output, but they also +check section names for special sections, like .note.GNU-stack. It is +inappropriate to set its type to SHT_NOTE. + +Revert + +commit c8db2c887b4129732341c4a1a51cdcd3191db271 +Author: Jan Beulich <[email protected]> +Date: Fri Jan 9 08:39:38 2026 +0100 + + ELF: give .note.GNU-stack proper section type + +and add tests to verify that .note.GNU-stack section has the SHT_PROGBITS +type. + +gas/ + + PR ld/33780 + * as.c (main): Don't set .note.GNU-stack section type to SHT_NOTE. + * testsuite/gas/elf/elf.exp: Run section-GNU-stack. + * testsuite/gas/elf/section-GNU-stack.d: New file. + * testsuite/gas/elf/section-GNU-stack.s: Likewise. + +ld/ + + PR ld/33780 + * ldelf.c (ldelf_after_open): Don't set .note.GNU-stack section + type to SHT_NOTE. + * testsuite/ld-elf/pr33780a.d: New file. + * testsuite/ld-elf/pr33780b.d: Likewise. + * testsuite/ld-elf/pr33780c.d: Likewise. + +Signed-off-by: H.J. Lu <[email protected]> +--- + gas/as.c | 1 - + gas/testsuite/gas/elf/elf.exp | 1 + + gas/testsuite/gas/elf/section-GNU-stack.d | 5 +++++ + gas/testsuite/gas/elf/section-GNU-stack.s | 1 + + ld/ldelf.c | 6 ++---- + ld/testsuite/ld-elf/pr33780a.d | 9 +++++++++ + ld/testsuite/ld-elf/pr33780b.d | 9 +++++++++ + ld/testsuite/ld-elf/pr33780c.d | 16 ++++++++++++++++ + 8 files changed, 43 insertions(+), 5 deletions(-) + create mode 100644 gas/testsuite/gas/elf/section-GNU-stack.d + create mode 100644 gas/testsuite/gas/elf/section-GNU-stack.s + create mode 100644 ld/testsuite/ld-elf/pr33780a.d + create mode 100644 ld/testsuite/ld-elf/pr33780b.d + create mode 100644 ld/testsuite/ld-elf/pr33780c.d + +diff --git a/gas/as.c b/gas/as.c +index d0e508cb2e3..200835b9311 100644 +--- a/gas/as.c ++++ b/gas/as.c +@@ -1505,7 +1505,6 @@ main (int argc, char ** argv) + gnustack = subseg_new (".note.GNU-stack", 0); + bfd_set_section_flags (gnustack, + SEC_READONLY | (flag_execstack ? SEC_CODE : 0)); +- elf_section_type (gnustack) = SHT_NOTE; + } + #endif + +diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp +index 35e06ce58b3..35273d42d0c 100644 +--- a/gas/testsuite/gas/elf/elf.exp ++++ b/gas/testsuite/gas/elf/elf.exp +@@ -389,5 +389,6 @@ if { [is_elf_format] } then { + + run_dump_test "bignums" $dump_opts + run_dump_test "section-symbol-redef" ++ run_dump_test "section-GNU-stack" + run_dump_test "pr27228" + } +diff --git a/gas/testsuite/gas/elf/section-GNU-stack.d b/gas/testsuite/gas/elf/section-GNU-stack.d +new file mode 100644 +index 00000000000..9bdc4d23ccd +--- /dev/null ++++ b/gas/testsuite/gas/elf/section-GNU-stack.d +@@ -0,0 +1,5 @@ ++#readelf: -SW ++ ++#... ++ \[[ 0-9]+\] \.note\.GNU-stack[ \t]+PROGBITS[ \t]+0+ +[0-9a-f]+ +0+ +00 +0 +0 +1 ++#pass +diff --git a/gas/testsuite/gas/elf/section-GNU-stack.s b/gas/testsuite/gas/elf/section-GNU-stack.s +new file mode 100644 +index 00000000000..a096c762633 +--- /dev/null ++++ b/gas/testsuite/gas/elf/section-GNU-stack.s +@@ -0,0 +1 @@ ++ .section .note.GNU-stack +diff --git a/ld/ldelf.c b/ld/ldelf.c +index fe4ab17b01f..a67f540b2df 100644 +--- a/ld/ldelf.c ++++ b/ld/ldelf.c +@@ -1327,10 +1327,8 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd, + effect. Instead we create a .note.GNU-stack section in much the + same way as the assembler does with its --[no]execstack option. */ + 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) +- elf_section_type (s) = SHT_NOTE; ++ (void) bfd_make_section_with_flags (link_info.input_bfds, ++ ".note.GNU-stack", flags); + } + return; + } +diff --git a/ld/testsuite/ld-elf/pr33780a.d b/ld/testsuite/ld-elf/pr33780a.d +new file mode 100644 +index 00000000000..a4a199d72a6 +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr33780a.d +@@ -0,0 +1,9 @@ ++#source: empty.s ++#ld: -r -z noexecstack --format=binary ++#readelf: -SW ++# These targets don't support -z. ++#xfail: [uses_genelf] ++ ++#... ++ \[[ 0-9]+\] \.note\.GNU-stack[ \t]+PROGBITS[ \t]+0+ +[0-9a-f]+ +0+ +00 +0 +0 +1 ++#pass +diff --git a/ld/testsuite/ld-elf/pr33780b.d b/ld/testsuite/ld-elf/pr33780b.d +new file mode 100644 +index 00000000000..d35c0bd84cb +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr33780b.d +@@ -0,0 +1,9 @@ ++#source: empty.s ++#ld: -r -z noexecstack ++#readelf: -SW ++# These targets don't support -z. ++#xfail: [uses_genelf] ++ ++#... ++ \[[ 0-9]+\] \.note\.GNU-stack[ \t]+PROGBITS[ \t]+0+ +[0-9a-f]+ +0+ +00 +0 +0 +1 ++#pass +diff --git a/ld/testsuite/ld-elf/pr33780c.d b/ld/testsuite/ld-elf/pr33780c.d +new file mode 100644 +index 00000000000..b5ff68e262e +--- /dev/null ++++ b/ld/testsuite/ld-elf/pr33780c.d +@@ -0,0 +1,16 @@ ++#source: property-or-1.s ++#as: --generate-missing-build-notes=no ++#ld: -r -z noexecstack ++#readelf: -n ++#xfail: ![check_shared_lib_support] ++#notarget: am33_2.0-*-* hppa*-*-hpux* mn10300-*-* ++# Assembly source file for the HPPA assembler is renamed and modifed by ++# sed. mn10300 has relocations in .note.gnu.property section which ++# elf_parse_notes doesn't support. ++ ++#... ++Displaying notes found in: .note.gnu.property ++[ ]+Owner[ ]+Data size[ ]+Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: UINT32_OR \(0xb000ffff\): 0x3 ++#pass + +base-commit: 93285ef5f3106df2016fdd231121bbfcf92ead51 +-- +2.52.0 +
