pub enum Protector {
None,
Buffers,
Strong,
All,
}Expand description
Which functions get a stack protector, which is what the -fstack-protector family decides.
The question is about the locals a function has, so it is answered here and not in the back
end: by the time a frame is laid out the types are gone and every local is a size and an
alignment. What the back end then does about the answer is its own business, and it is carried
to it as rucc_ir::AttrSet::STACK_PROTECT on the function.
The names are gcc’s, and so are the rules. A build that has been compiled with one of these for twenty years is entitled to the same set of protected functions from a compiler claiming to be compatible, because the ones left out are the ones an exploit goes looking for.
Variants§
None
None of them, which is -fno-stack-protector and what a command line that says nothing
gets.
Buffers
A function with a local array of at least eight bytes, or one whose stack grows while it
runs. -fstack-protector, which is the original and the narrowest.
Strong
Any of those, and any function with a local array at all, a local holding one, or a local
whose address is taken. -fstack-protector-strong, which is what every distribution builds
its packages with and therefore the one a real build line carries.
All
Every function that has a frame at all. -fstack-protector-all.