by mjijackson · 14y ago · 0 comments
I read this back in college, ages ago. Still relevant - not quite up there with K&R as far as technical writing goes, but it does indeed do the job of making a theoretical problem into an understandable & exploitable one, and for that reason "Smashing the Stack For Fun And Profit" is a phrase that has a special place in my heart.
gcc -S -o example1.s example1.c
However, example1.s looks very different on Mac than on Linux, in particular, on Mac the parameters are pushed in reverse order:
Leh_func_begin2: ...
movl $1, %eax
movl $2, %ecx
movl $3, %edx
movl %eax, %edi
movl %ecx, %esi
callq _function
Whereas on Linux, they are pushed in the order specified in that link: movl $3, %edx
movl $2, %esi
movl $1, %edi
call function
What is the reason behind this? Is it that the stack on OS X is implemented to grow up instead of down?