[英]GOTPCREL(%rip) in GAS Intel syntax
How can i write following: movq variable@GOTPCREL(%rip), %r8
in GAS Intel syntax?我如何编写以下内容:
movq variable@GOTPCREL(%rip), %r8
in GAS Intel 语法?
.intel_syntax noprefix
allows only this: mov r8, variable@GOTPCREL
, it does not understand ()
, and resulting code is different - i receive segmentation fault. .intel_syntax noprefix
只允许这样: mov r8, variable@GOTPCREL
,它不理解()
,结果代码不同 - 我收到分段错误。 How can i specify RIP-relative addressing?如何指定 RIP 相对寻址?
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.我更喜欢 Intel 语法,我的代码主要使用它。 This switcher is inconvenience when porting code to GAS.
这个切换器在将代码移植到 GAS 时很不方便。 Is it possible to write it shortly in Intel syntax?
是否可以用 Intel 语法快速编写它?
It's the standard effective address syntax.这是标准的有效地址语法。 As such, you write it as
mov r8, [variable@GOTPCREL + rip]
因此,您将其写为
mov r8, [variable@GOTPCREL + rip]
The syntax GAS expects for RIP relative addressing when using Intel syntax is displacement [rip]
.当使用英特尔语法时,GAS 期望 RIP 相对寻址的语法是
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. GAS 也将接受
[rip + displacement ]
以及其他一些形式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.