有没有人能帮我理解这个命令:
mov %esp,%edi
lea 0x10(%edi),%esi
首先,我将esp
的地址加载到edi
。然后加载edi+10
的值,这意味着将esp+10
的地址加载到esi
。但是,这对堆栈意味着什么呢?如果我做一个推送,我会在堆栈上写4个字节,对吗?如果我在堆栈上跳回10个字节,这一点在哪里?
|______| # here?
|______|
|______|
|______|
|______|
|______|
|______|
|___*__| # or at the position of the star?
|______| # 4 Byte
|______| # also 4 Byte long...
|______| <---%edi
发布于 2013-06-11 23:41:52
你用的是x86,不是x64,对吧?我将假设这一点。
“这对堆栈意味着什么?”
mov %esp,%edi
lea 0x10(%edi),%esi
此代码不会对堆栈操作(push
、pop
等)产生任何影响。这是因为堆栈操作作为堆栈指针在esp
寄存器上工作。上面的代码没有更改esp
,所以就堆栈而言,没有任何更改。
“如果我执行推送,我会在堆栈上写入4个字节,对吗?”:
不一定。x86支持16位和32位操作数的推送操作,因此写入堆栈的字节数取决于推送操作的大小。例如:
push %ax ; will push 2 bytes on the stack (sizeof(ax) == 2)
push %eax ; will push 4 bytes on the stack (sizeof(eax) == 4)
请注意,push还减去了sizeof(op1)
的esp
。
“如果我在堆栈上跳回10个字节,这一点在哪里?”
esi
上的lea
命令不会更改堆栈指针。所以,
nop ; 10 points back on the stack here
mov %esp,%edi
lea 0x10(%edi),%esi
nop ; will be the exact same location as here.
; relative to esi, this location is (esi - 26)
https://stackoverflow.com/questions/17047310
复制相似问题