Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access stack base pointer (rbp) using inline assembly?

My requirement is to access a function call parameters by offsetting rbp using inline assembly. But I couldn't find a suitable operand constraint to specify the base pointer in x86. I am using Intel compiler but it's documentation states that it supports GCC style inline assembly. So GCC based example would be sufficient.

like image 680
chamibuddhika Avatar asked Jun 19 '26 04:06

chamibuddhika


1 Answers

I know you asked for inlined assembly, but note that on gcc you could also use __builtin_frame_address, which both frees you from the need for inlined assembly (yikes), and could provide frame levels further than the immediate one.

See here - http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html

like image 109
Leeor Avatar answered Jun 22 '26 11:06

Leeor