Is there a way to make the stack of a C program executable through compilation?
I did
$ gcc -o convert -g convert
and then run
$ readelf -l convert
to check if the stack is executable but the output was:
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
The correct way to make the stack executable doesn't require that stack canaries be disabled, unlike what the accepted answer suggests.
Here's the correct way:
gcc -z execstack ...
What this does is, the -z
option of gcc
is passed to the linker [source]:
keyword
-z is passed directly on to the linker along with the keyword keyword. See the section in the documentation of your linker for permitted values and their meanings.
From man ld
[source]:
execstack
Marks the object as requiring executable stack.
-fno-stack-protector
should do the trick for you.
User contributions licensed under CC BY-SA 3.0