-fstack-protect

Mike Harrold alexmudmiko@gmail.com
Wed Jan 14 15:25:00 GMT 2015


Hello,

Is there a way to disable this for a specific function?  Something
like __attribute__((unprotected)) maybe?

I have a function that appends two string literals* (of known size to
the compiler) into a char array that is 43 bytes larger than the two
literals, but gcc is still emitting the stack guard instructions.

Since I know the stack cannot be smashed (and gcc is apparently unable
to determine that for itself), I'd like to turn it off for that
function.  It's a a heavily used function that is inlined, so it's
causing increased code size and slower performance for no reason.

Thanks,
--Mike

*It actually does more, but eliminating all but these two memcpy()s
still produces the stack guard; if reduced to a single memcpy(), gcc
does detect it cannot smash the stack and doesn't emit the stack
guard.



More information about the Gcc-help mailing list