-stack_protector/-stack_protector_all [Professional Edition only] [V1.02 or later] |
This option generates a code for detection of stack smashing.
A code for detection of stack smashing is not generated.
A 2-byte area is allocated just before the local variable area (in the direction towards address 0xFFFFF) at the entry to a function, and the value specified by num is stored. After that, the 2-byte area in which num was stored is checked for smashing at the end of the function. If smashing has occurred, the __stack_chk_fail function is called. |
The __stack_chk_fail function needs to be created by the user. It should be defined as a function having no parameters or return values, it should be located in the far area, and the processing to be executed at stack smashing should be written. |
When calling another function in the __stack_chk_fail function, note that stack smashing is not detected recursively in the function that was called. |
If -stack_protector is specified, this option generates a code for detection of stack smashing for only functions having a structure, union, or array that exceeds eight bytes as a local variable. |
If -stack_protector_all is specified, this option generates a code for detection of stack smashing for all functions. |
If this option is used simultaneously with #pragma stack_protector, the specification by #pragma stack_protector becomes valid. |
A code for detection of stack smashing is not generated for the functions in which the following is specified. |
#pragma inline, __inline keyword, #pragma inline_asm, #pragma no_stack_protector, #pragma rtos_interrupt, or #pragma rtos_task