This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
How to get the offset of a local variable relative to the stack frame address
- From: "gkourtis at freemail dot gr" <gkourtis at freemail dot gr>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 9 Jun 2016 14:15:34 +0300
- Subject: How to get the offset of a local variable relative to the stack frame address
- Authentication-results: sourceware.org; auth=none
The offset of a local variable relative to the frame address in C or C++
may be found by||:
||
|(char*)&a -(char*)__builtin_frame_address(0)|
||
|||A more straightforward builtin should be already available by gcc.
Which is it ?|
||
|p.s. the previous code adds the offset to bp and afterwards subtracts
from the result bp.|
||
||||
||
||