Re: Executable stack

Segher Boessenkool <[email protected]>
Newsgroups gmane.comp.gcc.help
Message-ID <aSCkxgPwmPQI_Hv-@gate>
Hi!

On Thu, Nov 20, 2025 at 05:57:33PM +0100, jh--- via Gcc-help wrote:
> I ported and cross-compiled gcc 15.1.0 to a custom OS on an ARM CPU. I am by
> no way an expert in this, so maybe my mistake is trivial. I used
> musl-cross-make if that is relevant.
> My project finally compiled, but I get the follow warning, by using this
> command line:
> arm-koolos-musleabihf-g++ -o ./build/ControlPanel.elf @"ControlPanel.txt"
> -L. -L/path-to-prefix/arm-koolos-musleabihf/lib -lkool -g1 -mfpu=vfpv3
> -mfloat-abi=hard -mcpu=cortex-a9 -Xlinker -Map=./build/ControlPanel.map
> -static -Wl,-T -Wl,lscript_static.ld
> 
> /path-to-prefix/arm-koolos-musleabihf/bin/ld: warning:
> /path-to-prefix/arm-koolos-musleabihf/15.1.0/crtend.o: missing
> .note.GNU-stack section implies executable stack
> /path-to-prefix/arm-koolos-musleabihf/bin/ld: NOTE: This behaviour is
> deprecated and will be removed in a future version of the linker
> 
> I threw readelf at the file and there doesn't seem to be much in it. Also,
> the file seems to be generated somehow, but I'm sure where I could add a
> .note directive as seem for example in a Redhat blog.
> 
> How can I fix this problem?

As it says, there is no .note.GNU-stack section, and you do not disable
executable stack output some other way (like by usig the -z noexecstack
linker flag), so the default is (like it has been since forever) to keep
the stach executable, as your ABI requires btw.

Your OS port likely wants to default to not have the stack executable.
For example, the linux-elf.h file does

/* Add .note.GNU-stack.  */
#undef NEED_INDICATE_EXEC_STACK
#define NEED_INDICATE_EXEC_STACK	1

for this.

Gl;hf,


Segher
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.