This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: stack-checking
- From: Zack Weinberg <zack at codesourcery dot com>
- To: kavii ita <systemonchip2000 at yahoo dot co dot in>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 26 Jul 2004 08:55:04 -0700
- Subject: Re: stack-checking
- References: <20040726094334.2060.qmail@web8307.mail.in.yahoo.com>
kavii ita <systemonchip2000@yahoo.co.in> writes:
> hello,
>
> I am working on an embedded system, which runs elf images and have
> no underlying OS.
>
> I have modified GCC to check at the start of each function whether
> the current stack pointer is out of range..i.e. to check stack
> overflow.
>
> My problem is how can I print diagnostic messages when stack
> overflow occurs? Since once the overflow occurs , the functions
> printf etc does not work as they themselves need stack space.
This question is more suited to an embedded-operating-system
development forum, but I don't know of one offhand, so I'll give you a
suggestion: Have gcc respond to stack overflow by issuing a hardware
trap. Give the trap handler its own stack (all modern CPUs can do
that). Then you have space to issue an error message.
zw