ARM assembly : .LANCHOR0

十年热恋 提交于 2021-01-28 00:04:37

问题


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

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

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;

But, what does

.L10:
        .word   .LANCHOR0

do? There is no label preceding .word here.

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

Thanks in advance.

UPDATE

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

.L7:
        .word   131586
        .word   .LANCHOR0

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?


回答1:


The following line

.L10:
  .word   .LANCHOR0

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

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.



来源:https://stackoverflow.com/questions/55433736/arm-assembly-lanchor0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!