You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we use stack variables in function (and if frame pointer is enabled) we address to the stack variables using access relative to FP register (instead of SP). The advantages of such FP usage are not clear and there is one big issue with it - the ARC HW stack checking checks the instructions, which use SP as the base register - so if we use FP the illegal access to stack are not caught by HW.
The simplest way to reproduce such behavior is to build code without optimization, i.e.:
NOTE: the MWDT toolchain generates access to the stack variables with SP used as a base (so HW stack checking works correctly) and the issue exists only with GNU toolchain.
The text was updated successfully, but these errors were encountered:
If we use stack variables in function (and if frame pointer is enabled) we address to the stack variables using access relative to FP register (instead of SP). The advantages of such FP usage are not clear and there is one big issue with it - the ARC HW stack checking checks the instructions, which use SP as the base register - so if we use FP the illegal access to stack are not caught by HW.
The simplest way to reproduce such behavior is to build code without optimization, i.e.:
It's not clear why we use FP instead of SP here and if there is a way to avoid it (without just disabling frame pointer for the build).
Note that we can easily replace FP by SP here without making code bigger, etc.. Here is an example:
original asm:
alternative asm:
NOTE: the MWDT toolchain generates access to the stack variables with SP used as a base (so HW stack checking works correctly) and the issue exists only with GNU toolchain.
The text was updated successfully, but these errors were encountered: