pub enum Protector {
None,
Buffers,
Strong,
All,
}
Expand description
Which functions get a stack protector, which is what the -fstack-protector family asks.
A canary is a word the prologue copies into the frame above everything a local can be written
through, and the epilogue compares it against the copy the runtime still holds before it
returns. A write that runs off the end of a local and keeps going passes the canary on its way
to the return address, so a function that returns with the word changed calls
__stack_chk_fail instead of returning at all.
Which functions are worth the slot and the comparison is what the three levels disagree about,
and the middle one is the one that matters: every distribution has built its packages with
-fstack-protector-strong for a decade, so a compiler that cannot take the flag cannot be the
CC of a package build whatever else it can do.
-fno-stack-protector, and what a command line that says nothing gets. gcc’s own default
is the same, and it is the distributions rather than the compiler that turn it on.