How to make a stack of executable program C?

Is there a way to make the C program stack executable using 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
+3
source share
2 answers

-fno-stack-protector should do the trick for you.

-4
source

The right way to make the stack executable does not require disabling the stack canaries, unlike what the accepted answer offers.

Here is the correct way:

gcc -z execstack ...

To do this, the option -zis gccpassed to the linker [ source ]:

keyword

-z . . .

man ld []:

execstack

.

+2

All Articles