获取当前指令的x86地址指令、地址

2023-09-07 22:11:19 作者:再好的网名也会被人备注掉

我使用的Linux使用x86(64位为precise)。有没有一种方法可以让我得到当前指令的地址。其实我想写的的setjmp / longjmp的我自己的简化版本。 这里,R ..发布的的longjmp 的简化版本。任何想法如何的setjmp 的实施。一个简化版本,也就是说,在不考虑异常和信号等...

I am using Linux with x86 (64 bit to be precise). Is there a way I can get the address of the current instruction. Actually I want to write my own simplified versions of setjmp/longjmp. Here, R.. posted a simplified version of longjmp. Any idea how setjmp is implemented. A simplified version that is, without taking into account of exceptions and signals etc...

推荐答案

我相信,在64位code,可根本就 LEA RAX,[RIP]

I believe in 64-bit code you can simply do lea rax, [rip].

32位的成语是:

      call next
next: pop eax