This is a question that has bothered me for more than twenty-five years.
Blame it on my being one of those forthies, I guess. Recent posts encourage
me to ask again.

Is there any good reason for interleaving the return addresses with data on
the data/parameter stack in C? I know it's the tradition, from back when it
was all we could hope for to have one page per process, but that has not
been the case for many years, I think.

Adding code to the program preamble to reserve space for another stack with
mmap shouldn't be hard at all. Default address separation of about a
quarter to a half a gig should be reasonable in 32 bit address space, at
any rate. New compiler switches would be needed to tune the separation. I'm
pretty sure openbsd has the means to keep a largish no-access region
between the stacks.

The call protocol itself should be simpler, although I might expect some
debate about which stack to push frame pointers to when pushing frame
pointers. The problem, I think, is in convincing the compiler to refrain
from moving the frame pointer to the stack pointer on function entry. Maybe.

To those on the list who are intimate with the compiler(s), how difficult
would it be to change the function call protocol to push the program
counter to a separate stack from the parameters and locals?

Or am I speculating about a different world, still?

Joel Rees

Computer memory is just fancy paper,
CPUs just fancy pens.
All is a stream of text
flowing from the past into the future.

Reply via email to