开发者

What's wrong with this statement on x86-64?

This function aims to开发者_JAVA百科 get the start address of the stack:

unsigned long find_start(void){
        __asm__("movq %rsp, %eax");
}

When I compile it,getting an error:

Error: suffix or operands invalid for `movq'


movq is an instruction that expects 64-bit operands. rsp is a 64-bit register, while eax is a 32-bit register.

Perhaps try rax?


%eax is the 32-bit GP register. However you are trying to do a 64-bit move with it. It should be %rax.


You need, as stated, to use the 64-bit register %rax.

Regarding the fact that the stack pointer is different each time, I suspect that you are seeing the results of address space layout randomization, and in real time at that...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜