本文介绍了ARM 程序集:.LANCHOR0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 ARM 汇编相对缺乏经验,需要帮助理解几行.我已经使用 Godbolt 用 ARM gcc 8.2 编译器编译了 C++ 11 代码并得到了这些汇编行:

I am relatively inexperienced with ARM assembly, and need help understanding a few lines. I have used Godbolt to compile C++ 11 code with the ARM gcc 8.2 compiler and got these lines of assembly:

.L10:
        .word   .LANCHOR0

我读到 .LANCHOR0 是部分锚点,但这是什么意思?

I read that .LANCHOR0 are section anchors, but what does that mean?

我知道 .word 和 .data 可以一起使用来声明变量并将值分配给内存空间,如下所示:

I understand that .word and .data can be used together to declare variables and assign values to memory spaces like this:

        .data           ! start a group of variable declarations
x:      .word   23      ! int x = 23;

但是,什么

.L10:
        .word   .LANCHOR0

做什么?.word 前面没有标签.

do? There is no label preceding .word here.

其次,当一个 .word 行块被另一个像这样的汇编指令块处理时,这意味着什么?

Secondly, what does it mean when a block of .word lines are proceeded by another block of assembly instructions like this?

.L7:
        .word   131586
        .word   .LANCHOR0
_GLOBAL__sub_I_unsigned int atlantic_line_ns::getSimInstAddr<atlantic_line_ns::Cr>():
        mov     r2, #0
        ldr     r3, .L10
        str     r2, [r3]
        str     r2, [r3, #4]
        bx      lr

提前致谢.

更新

阅读ARM文档后,我明白了

After reading the ARM documentation a bit more, I understand that

.L7:
        .word   131586
        .word   .LANCHOR0

分配 2 个内存位置,存储值 131586 和 .LANCHOR0 处的值.这些内存位置是否彼此相邻?另外,.LANCHR0 是什么意思?

Allocates 2 memory locations, storing values, 131586 and the value at .LANCHOR0, there. Are these memory locations next to each other? Also, what does .LANCHR0 mean?

推荐答案

下面一行

.L10:
  .word   .LANCHOR0

指示汇编器分配 4 个字节来保存 .LANCHOR0 标签处的代码/数据地址.地址本身位于标签 .L10.请注意,.LANCHOR0.L10 都是普通的本地标签(后缀仅表示编译器将它们用于不同的目的).

instructs assembler to allocate 4 bytes to hold the address of code/data at .LANCHOR0 label. The address itself is located at label .L10. Note that both .LANCHOR0 and .L10 are ordinary local labels (suffix simply denotes that compiler used them for different purposes).

正如您所指出的,可以在汇编中混合代码和只读数据,例如在

As you noted, it's possible to intermix code and readonly data in assembly as e.g. in

.L7:
  .word   131586
  .word   .LANCHOR0
  mov     r2, #0
  ldr     r3, .L10

编译器经常这样做以声明局部函数数据(文字池、静态变量等)..word 行中的数据在目标代码中也将是连续的.

Compiler frequently does this to declare local function data (literal pool, static variables, etc.). Data from .word lines next to each other will also be consecutive in object code.

这篇关于ARM 程序集:.LANCHOR0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 08:15