Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get address of current instruction for x86 [duplicate]

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...

like image 701
MetallicPriest Avatar asked Oct 28 '11 16:10

MetallicPriest


1 Answers

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

The 32-bit idiom is:

      call next
next: pop eax
like image 60
NPE Avatar answered Sep 25 '22 07:09

NPE