_function pushl $retAddr jmp _function retAddr: movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret %esp 28ff1c %ebp 28ff28 %eax $99 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 8(%esp) $99 4(%esp) $LC0 (%esp) address of next instruction We push the address of the next instruction to the stack.
_function pushl $retAddr jmp _function retAddr: movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret %esp 28ff1c %ebp 28ff28 %eax $99 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 8(%esp) $99 4(%esp) $LC0 (%esp) address of next instruction We push the address of the next instruction to the stack. We jump to _printf and do our business
_function pushl $retAddr jmp _function retAddr: movl %eax, 4(%esp) movl $LC0, (%esp) call _printf movl $0, %eax leave ret %esp 28ff1c %ebp 28ff28 %eax $99 12(%ebp) argv 8(%ebp) argc 4(%ebp) return addr (%ebp) old %ebp 8(%esp) $99 4(%esp) $LC0 (%esp) address of next instruction We push the address of the next instruction to the stack. We jump to _printf and do our business When finished, _printf jumps to our next instruction