When making a function call in Linux (or OS X for that matter), can the callee modify the values of the arguments on the stack? I was under the assumption that since the caller is the one that cleans them up, that they should contain the same values after the function call. However I found that GCC with -O2 was modifying parameters that were passed to it on the stack. I have also looked for documentation including the System V i386 calling conventions, but was unable to find a definitive answer to this.
Here is some sample code I was debugging.
pushl %eax # %eax = 0x28
call _print_any
popl %eax
# %eax is now 0x0a
I would assume that GCC modifying that parameter on the stack is fine, but I want to know where it is specified that it can do so.