This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stack-checking


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]