Hello,
i am writing a simple c program and my requirement is to print RIP(Instruction Pointer) from some function of the program. i dont want to use ptrace.
the one thing i tried with inline asm is: asm("movl %%rip, %0;" : "=r"(val) ) this should copy my rip register value to variable val, but i am getting compilation error.
if i use ebp/esp which are base pointer and stack pointers for 32 bit machine, i dont get any compilation error and my val has some hexadecimal number assigned.
i have few questions here:
1) as my machine is 63 bit, how was above instruction able to read 32 bit registers?
2) why i am not able to read any register for 64 bit, is there any issue b'caz of 'r'?
3) when i use eip which is for 32 bit i get compilation error, does it mean IP registers are restricted for reading?
Thanks. Sandeep