Reputation: 161
How can i write following: movq variable@GOTPCREL(%rip), %r8
in GAS Intel syntax?
.intel_syntax noprefix
allows only this: mov r8, variable@GOTPCREL
, it does not understand ()
, and resulting code is different - i receive segmentation fault. How can i specify RIP-relative addressing?
At this moment i have to use following syntax switcher:
.att_syntax
movq variable@GOTPCREL(%rip), %r8
.intel_syntax noprefix
I prefer Intel syntax, and my code uses it mostly. This switcher is inconvenience when porting code to GAS. Is it possible to write it shortly in Intel syntax?
Upvotes: 1
Views: 1911
Reputation: 39621
The syntax GAS expects for RIP relative addressing when using Intel syntax is displacement[rip]
. So for example:
.att_syntax
movq variable@GOTPCREL(%rip), %r8
.intel_syntax noprefix
mov r8, variable@GOTPCREL[rip]
$ as test.s
$ objdump -d -r
a.out: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 4c 8b 05 00 00 00 00 mov 0x0(%rip),%r8 # 0x7
3: R_X86_64_REX_GOTPCRELX variable-0x4
7: 4c 8b 05 00 00 00 00 mov 0x0(%rip),%r8 # 0xe
a: R_X86_64_REX_GOTPCRELX variable-0x4
GAS will also accept [rip + displacement]
and maybe some other forms.
Upvotes: 0
Reputation: 58782
It's the standard effective address syntax. As such, you write it as mov r8, [variable@GOTPCREL + rip]
Upvotes: 1