这是什么汇编语句是什么意思?语句、这是什么

2023-09-08 00:21:19 作者:如期而至*

我在看GCC所生成的使用-s标志大会code。有些语句看起来像下面这样。

I am looking at the assembly code generated by gcc by using the -s flag. Some statements look like the following.

movl    is_leader(%rip), destination

下面, is_leader 是一个全局定义类型的变量 INT 在C code。我不明白的是这里的长期的 is_leader(%RIP)。是不是裂口指令指针?我需要知道这是怎么语句用于访问的 is_leader

Here, is_leader is a globally defined variable of type int in the C code. What I don't understand is the term is_leader(%rip) here. Isn't rip the instruction pointer? I need to know how is this statement used to access is_leader.

推荐答案

它要求汇编器code,增加或减去当前指令的地址和对象的指令指针的地址之间的差异

It asks the assembler to generate code that adds or subtracts the difference between the address of the current instruction and the address of the object to the instruction pointer.

这给出了对象的地址,而不会产生一个绝对地址(一般,偏移配合到16或32位,所以所得到的code是也较短,从而更快)。

This gives the address of the object without generating an absolute address (and generally, the offset fits into 16 or 32 bits, so the resulting code is also shorter and thus faster).

这增加了,这两个项之间的距离保持恒定的约束,因此,这只能在同一个可加载的对象数据中使用;连接器会标志,如果不符合该条件的错误。

This adds the constraint that the distance between both items remains constant, so this can be used only for data in the same loadable object; the linker will flag an error if that condition is not met.