Re: Syscall changes registers beyond %eax, on linux-i386

Richard Henderson
2002-09-19T18:53:04Z

On Thu, Sep 19, 2002 at 02:51:44PM -0400, Brian Gerst wrote:
> > The parameter area belongs to the callee, and it may *always* be modified.
>
> The parameters can not be modified if they are declared const though,
> that's my point.

Yes they can.

extern void bar(int x, int y, int z);
void foo(const int a, const int b, const int c)
{
bar(a+1, b+1, c+1);
}

subl $12, %esp
movl 20(%esp), %eax
incl %eax
movl %eax, 20(%esp)
movl 16(%esp), %eax
incl %eax
incl 24(%esp)
movl %eax, 16(%esp)
addl $12, %esp
jmp bar

(Not sure why gcc doesn't use incl on all three memories, nor
should it allocate that stack frame...)

r~