获取 x86 的当前指令地址 [英] Get address of current instruction for x86

查看:41
本文介绍了获取 x86 的当前指令地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 x86(准确地说是 64 位)上使用 Linux.有没有办法获得当前指令的地址.实际上,我想编写自己的 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 位代码中,您可以简单地执行 lea rax, [rip].

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

32 位的习惯用法是:

The 32-bit idiom is:

      call next
next: pop eax

这篇关于获取 x86 的当前指令地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆