With gcc
, is it possible to compile with -fstack-protector
, but omit for a specific function.
For example, say i have two functions.
void a() {
...
}
void b() {
...
}
Can I tell the compiler to compile a program that will use a canary before the saved return address of a
, but no canary for b
?
CodePudding user response:
You'd have to test if it works (inspect the generated code at Godbolt) but it looks like you can do, for example:
__attribute__ ((no_stack_protector)) void foo () { ... }
no_sanitize
looks like an intriguing option, I wonder who uses that.