[PATCH v2] elf: Don't set .note.GNU-stack type to SHT_NOTE

Jan Beulich jbeulich@suse.com
Wed Jan 14 07:52:02 GMT 2026


On 14.01.2026 00:37, H.J. Lu wrote:
> GCC generates:
> 
> .section .note.GNU-stack,"",@progbits

May want changing then, too. Why would it do this anyway? It could pass
--{,no}execstack to gas and be done?

> .note.GNU-stack type has been SHT_PROGBITS.   According to gABI,
> an empty SHT_NOTE section doesn't contribute anything.   A linker can
> discard an empty SHT_NOTE section.

None of this is said in the gABI, though? Or else please provide quotations.

>   Can someone show benefits of changing .note.GNU-stack to SHT_NOTE?

As previously indicated, to have

	*(.note .note.*)

work reliably in linker scripts, without needing to special-case
.note.GNU-stack (in the script) and without becoming dependent upon the
ordering of the various .note.* contributions in the input objects. As said
before, .note.GNU-stack being PROGBITS and (with recent binutils, due to a
linker script change of yours iirc) suddenly appearing first in the output
of "ld -r" with "suitable" inputs made the output .note section be PROGBITS
in the eventual final binary (going from memory: then also not resulting in
a PT_NOTE segment).

Jan


More information about the Binutils mailing list