> AFAICT, it's enough to just align the stack before doing anything else.
> In this case it means aligning the stack somewhere before
> (exit(main(...)). gcc maintains proper alignment on an aligned stack.
I wouldn't rely on that, gcc is free to assume that it can address
local variables relative to the stack. In practice, it uses %ebp
unless you use -fomit-frame-pointer, but I don't think that
manipulating the stack pointer without gcc knowing about it is
guaranteed to be safe (alloca is a special case, gcc detects that it
is used internally). Future improvements in code generation would
also be likely to break things.
However, an easy alternative would be to make the _start entry point
an assembly language stub that calls a C function:
That would look something like this if done in crt1.c:
asm(".text; .globl _start; _start:;"
"lea 4(%esp),%eax;"
"andl $~15,%esp;"
"subl $4,%esp;"
"pushl %eax;"
"call c_start");
static void
c_start(char **argv)
{
etc...
This of course assumes that static symbols have naming conventions
identical to global symbols. (It can easily be made more predictable
by assigning the function a specific symbol)
> Maybe alignment can even be done in the kernel...
It gets messy, it has to be done before putting the env and argv
pointers in place... On program entry, (%esp) is argc, %esp + 4 is
the beginning of the argv array and env array is located immediately
after the argv array.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message