SPRAD28 October 2022 AM2431 , AM2432 , AM2434 , AM2631 , AM2631-Q1 , AM2632 , AM2632-Q1 , AM2634 , AM2634-Q1 , AM26C31 , AM26C31-EP , AM26C31M , AM26C32 , AM26C32-EP , AM26C32M , AM26LS31 , AM26LS31M , AM26LS32A , AM26LS32AC , AM26LS32AM , AM26LS33A , AM26LS33A-SP , AM26LS33AM , AM26LV31 , AM26LV31E , AM26LV31E-EP , AM26LV32 , AM26LV32E , AM26LV32E-EP , AM26S10 , AM2732 , AM2732-Q1
To enable stack smashing detection in your application, you need to provide definitions of:
__stack_chk_fail() - This function is called from an instrumented function when a check against the stack guard value, __stack_chk_guard, fails. A simple definition of this function might look like this:
void __stack_chk_fail(void) {
printf("__stack_chk_guard has been corrupted\n");
exit(0);
}
__stack_chk_guard
- This is a globally visible symbol whose value can be copied into a location at the
boundary of a function’s allocated stack on entry into the function, and loaded just
prior to function exit to perform a check that the local copy of the
__stack_chk_guard value has not been overwritten. A simple definition of this
symbol might look like
this:unsignedlong__stack_chk_guard=0xbadeebad;
You can then compile a file containing both of these definitions to preoduce an object file that can be linked into an application that is instrumented for stack smashing detection.