https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87220
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |ebotcazou at gcc dot gnu.org Resolution|--- |WORKSFORME --- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > -fstack-check produces the code (x86_64; similar for 32-bit): > > foo: > subq $4152, %rsp > orq $0, (%rsp) > addq $4128, %rsp > leaq 6(%rsp), %rdi > call bar > addq $24, %rsp > ret > > This test: > 1. Unnecessarily touches an extra page of stack that's not used, wasting > memory. It's as designed (the extra page is necessary to unwind the stack). > 2. Skips over a whole page, potentially clobbering (data race) data on the > other side of a guard page. Likewise, because of 1. > 3. Is completely unnecessary; since less than a page of stack is needed, > only a probe of the final desired stack pointer (after the third > instruction) is needed, and it's performed implicitly by the call. Likewise, because of 1. > The excessive stack usage, unsafety (jumping the guard page), and size and > potential performance hit from unnecessary checks seem to make -fstack-check > unsuitable for its intended purpose at this time. -fstack-check was designed to implement stack checking in Ada, it has nothing to do with stack protection, you want to use -fstack-clash-protection instead.