I have written an application in C, and I\'m trying to understand what is the purpose of the -fno-stack-protector
command when compiling. For my specific applic
If you compile with -fstack-protector
, then there will be a little more space allocated on the stack and a little more overhead on entry to and return from a function while the code sets up the checks and then actually checks whether you've overwritten the stack while in the function.
It will make a difference to your application. If enabled, it will head off stack overflow attacks quickly. Only if you have no function calls in your code would it leave your program unaffected (and since you normally write main()
, and that is a function which is called by the startup code, it would have an effect on your program). However, stack overflow attacks are not the only possible attacks that can be used, so it is not a panacea. But it is useful protection with a limited cost.
The protection does not depend on the system per se; it depends on the version of the compiler that you are using, but that's all.