Re: newbie questiom about %rip in x86-64 and var




Claudio Daffra wrote:
hi all

newbie questiom about %rip in x86-64,

this a toy program. and show use of types
about x86-64 var can be accesses with %rip
but %rip change always as indicate
i don't mean ? manual are in english
sure i have no translate correctly
can u explain with other simple word.


The point of IP-relative addressing is to allow you to embed data
(usually constants) close to the code that needs it, and to allow you
to access it without any relocation or addressing issues. Even better
the offsets required tend to be quite small (since the literals are
typically very close to the using code).

If it helps, think of IP-relative addressing not as relative to the IP
register, but rather as relative to the location in memory where the
referencing instruction is stored. As a more familiar example, think
of the way conditional jump instructions use IP-relative addressing for
their jump targets. Now extend that to referencing a few literals
stuffed in to the text section after the routine in question.

.