[PATCH v2] elf: Don't set .note.GNU-stack type to SHT_NOTE
Jan Beulich
jbeulich@suse.com
Wed Jan 14 08:02:03 GMT 2026
On 13.01.2026 18:33, Michael Matz wrote:
> There are more warts of .note.GNU-stack that need at least a little
> pondering:
> (a) the usage of section flags to convey information, i.e. being
> SHF_EXECINSTR to mean needing an executable stack.
> It's slightly surprising to find such flag on a SHT_NOTE section.
> (And what does it mean for the resulting PT_NOTE segment?)
> (b) in .s files the .note.GNU-stack section is often generated by
> .section .note.GNU-stack,"",@progbits
> it may be surprising if the resulting .o file has a SHT_NOTE type,
> instead of the explicitely requested SHT_PROGBITS
Experimentally, if --{,no}execstack is passed, it'll be NOTE irrespective
of the @progbits. But the combination of command line option and section
directive isn't overly well defined anyway, as the "exec" parts
accumulate. Without the command line option it'll continue to be PROGBITS.
> I think none of those would hinder the usage of SHT_NOTE for
> .note.GNU-stack. (a) shouldn't pose a problem anywhere, and the surprise
> is very limited.
Well, for people using --execstack that would mean an extra chunk of
executable "code" (really data). The same would have happened to them
before the change though, unless they special-cased .note.GNU-stack in
their linker scripts.
> For (b) the asm directive should probably continue to
> then make the gnu-stack section be SHT_PROGBITS, but either way the link
> editor needs to continue accepting PROGBITS .note.GNU-stack anyway, as a
> compatility measure.
Of course.
Jan
More information about the Binutils
mailing list