x1, %eax # load with 32bit sign extended relocation movl 0xffffffff, %eax # load with 64bit relocation movl symb, %eax # load with 32bit sign extended relocation movabsl symb, %eax # load with 64bit sign extended relocationLoads and stores with 64-bit displacement are available only for the eax instruction.
X86-64 defines a new instruction pointer relative addressing mode to simplify writing of position independent code. The original displacement-only addressing of are overwritten by this one and displacement only is now encoded by one of the redundant SIB form. This means that RIP relative addressing is actually cheaper than displacement only.
To encode this addressing, just write rip as yet another register:
movl $0x1, 0x10(%rip)will store the value 0x1 10 bytes after the end of the instruction.
Symbolic relocation will be implicitly RIP relative, so
movl $0x1, symb(%rip)Will write 0x1 to the address of symbol "symb".
FIXME: This looks particularly confusing in the Intel syntax [symb+rip] suggest different location than [symb]. Suggestions for better syntax with symbols?
You are recommended to use RIP relative addressing whenever possible to reduce code size.
The RIP relative branch instructions are still encoded equally to 32bit mode. This means that they are implicitly RIP relative and "*" is used to switch to absolute form.
(%rbp,index,scale)is not encodable and:
0(%rbp,index,scale)must be used.
This text was written by Jan Hubicka. Please send comments to email@example.com. (Note: The mailing list is now defunct. Refer mailing list for updates)