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

H.J. Lu hjl.tools@gmail.com
Wed Jan 14 09:36:42 GMT 2026


On Wed, Jan 14, 2026 at 3:52 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> 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?

You can raise this question to the gcc mailing list.

>
> > .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

Can you add a binutils testcase to show that your patch makes a difference
for this case?

> 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



-- 
H.J.


More information about the Binutils mailing list