简体   繁体   English

GOTPCREL(%rip) 在 GAS Intel 语法中

[英]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.

相关问题 x86-64 GAS Intel 语法中像“[RIP + _a]”这样的 RIP 相关变量引用如何工作? - How do RIP-relative variable references like "[RIP + _a]" in x86-64 GAS Intel-syntax work? `var@GOTPCREL(%rip)` 是什么意思? - What does `var@GOTPCREL(%rip)` mean? 将GAS与.intel_syntax一起使用时出错 - Error when using GAS with .intel_syntax 如果使用 Intel 语法,GAS 可以在非 Intel 系统上组装吗? - Can GAS assemble on non-Intel systems if Intel syntax is used? 如何将此代码从 Intel(nasm) 转换为 AT&amp;T(gas) 语法? - How to translate this code from Intel(nasm) to AT&T(gas) syntax? 将静态地址放入GNU AS(GAS).intel_syntax寄存器中? - Putting a static address into a register with GNU AS (GAS) .intel_syntax? 告诉 GAS 在 Intel 语法模式下使用分号进行注释 - Telling GAS to use semicolons for comments in Intel syntax mode 了解英特尔汇编中的 %rip 寄存器 - Understanding %rip register in intel assembly 为什么从 AT&amp;T 切换到 Intel 语法会使本教程使用 GAS 出现段错误? - Why does switching from AT&T to Intel syntax make this tutorial segfault using GAS? 在 GAS.intel-syntax 程序集中在 memory 标签和寄存器上使用“偏移”和“[]”有什么区别? - What is the difference between using “offset” and “[ ]” on memory labels and registers in GAS .intel-syntax assembly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM