Mail Archives: djgpp-workers/2003/02/11/01:05:06
On Mon, 10 Feb 2003, CBFalconer wrote:
> > Assuming that esp
> > has already decremented to point to the newly allocated space,
> > the possible overflow is detected thus:
>
> I don't believe you should make any such assumption. You cannot
> assume that anything called has stack checking code.
I think you misunderstood what Esa was saying (or else I misunderstood
it ;-). As I understand it, his code assumes to be called by GCC _after_
each change in ESP. There's no assumption that the calling code was
compiled with stack checking.
> So I
> consider you should ONLY check at function entry, when stack space
> is being allocated for locals.
If I understand correctly, here you assume that the code generated by the
compiler allocates space for locals only in the function prologue. This
is not true for latest versions of GCC, especially under -On optimization
options. Take a look at the code it emits, search for "esp", and you
will see how many stack adjustments are done during a function's life.
- Raw text -