Next: , Previous: -msmall-code, Up: Invocation

2.7 -mstackcheck

By default, the code generated by ‘GCC’ does not check if there is enough stack available before performing stack-consuming operations. This is generally not necessary on ‘UN*X’ systems, where the stack is extended automagically whenever needed.

Unfortunately, the AmigaOS provides tasks with a static, fixed size stack.

However, if a program is compiled with ‘-mstackcheck’, it will check if there is enough stack available before performing any stack-hungry operations. If there is a danger of stack overflow, the program will abort and the user will be notified.

Needless to say, stack checking increases the executable size and the execution time.

Note: Stack checking cannot be used for functions that might be called from outside your task. This includes interrupt handlers, shared library functions, hooks etc. In such cases, you should either avoid using ‘-mstackcheck’ for files containing such functions, or use __attribute__((interrupt)) (see interrupt).

It is safe to call a function that performs stack checking from one that does not, and vice versa.

The negative form of ‘-mstackcheck’ is ‘-mno-stackcheck’, and is on by default.

Warning: ‘-mno-stackcheck’ used to be called ‘-mnostackcheck’ before ‘Geek Gadgets’ snapshot ‘961012’.

For more information, please refer to the ‘LibNIX’ documentation.