At 03:22 27-08-05 +0200, you wrote:
>nobo...@web.de wrote:
>> in the stackcheck example &_end is used for the stack check 
>> and the comment says that _end is defined by the linker.
>> Because the heap begins behind the bss segment and grows
>> towards the stack this seem to mean that stackcheck can only work
>> if the heap is unused.
>> Is this right?
>
>yes
>
>
>if you have a heap (use of malloc/free) then the stack check has to be 
>done differently. one solution is to preclaculate a lowest allowed 
>address and put the stackmarker there:
>
>  extern unsigned short __stack;
>  unsigned short *address = (unsigned short *)(__stack-50);
>

Or write a small wrapper around malloc which determines which address is
still available for the stack.

Nico Coesel


Reply via email to