C-family stack check for threads

Thomas Klein th.r.klein@web.de
Mon Mar 21 11:19:00 GMT 2011


* Florian Weimer:
> * Thomas Klein:
>
>> e.g. if using "-fstack-check=indirect 
>> -fstack-limit-symbol=stack_limit_var"
> Have you looked at -fsplit-stack? It emits quite similar code.
>

Yes I have seen this.
But the switches -fstack-check and -fsplit-stack are for different cases.
The "stack check" (with a given limit) is used to to detect if a stack 
overflow has already taken place or if it will take place within the 
current function call.
While "split stack" is used to dynamically allocate more space (from 
Heap) if the current stack size is too small.
This mechanism is currently only supported for x86 machines (having a 
UNIX alike environment).

In my case I'm using a ARM microcontroller (without MMU) with 20KBytes 
of RAM in total.
I'm having 10 threads with a 1K stack for each.
Global variables allocating 8K and Heap having 2K.

I simply need a check method to detect if a function is going to write 
into the wrong stack area.

Regards
   Thomas






More information about the Gcc-patches mailing list