[binutils-gdb] ELF: give .note.GNU-stack proper section type

Jan Beulich jbeulich@sourceware.org
Fri Jan 9 07:48:41 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c8db2c887b4129732341c4a1a51cdcd3191db271

commit c8db2c887b4129732341c4a1a51cdcd3191db271
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Jan 9 08:39:38 2026 +0100

    ELF: give .note.GNU-stack proper section type
    
    Like all .note and .note.* sections it should be SHT_NOTE, not
    SHT_PROGBITS.

Diff:
---
 gas/as.c   | 2 +-
 ld/ldelf.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gas/as.c b/gas/as.c
index 3d035830c83..d0e508cb2e3 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1505,7 +1505,7 @@ 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/ld/ldelf.c b/ld/ldelf.c
index a67f540b2df..fe4ab17b01f 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1327,8 +1327,10 @@ 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);
-	  (void) bfd_make_section_with_flags (link_info.input_bfds,
-					      ".note.GNU-stack", flags);
+	  s = bfd_make_section_with_flags (link_info.input_bfds,
+					   ".note.GNU-stack", flags);
+	  if (s)
+	    elf_section_type (s) = SHT_NOTE;
 	}
       return;
     }


More information about the Binutils-cvs mailing list