由于我使用的是OSX,因此我需要对系统调用使用BSD调用约定,如下所示。
SECTION .text
push StringLen ; Push string length
push MyString ; Push the string
push 0x1 ; Push the file descriptor (stdout)
mov eax, 4 ; Push the system call (sys_write)
int 0x80 ; Call kernel dispatcher
add esp, 0x10 ; Clean up stack 16 bytes for 4DWORDS
mov eax, 1
mov ebx, 0
int 0x80 ; System exit我已经实验过了,在清理之后,这些值似乎仍然在堆栈上,但当另一个值被推送时,这些值就会被覆盖。
add esp, 0x10 ; Clean up stack 16 bytes for 4DWORDS
push 0x1A ; New push overwrites the previous stack values我确信这在一个小程序中不会有太大的不同,但是在一个大的程序中,如果它永远不会被覆盖,它是不是浪费了空间?
发布于 2013-03-14 23:16:59
不,这不是浪费的空间。堆栈空间的16个字节将一次又一次地重用。
https://stackoverflow.com/questions/15413073
复制相似问题