ARM汇编:.LANCHOR0 [英] ARM assembly : .LANCHOR0

查看:284
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆