简体   繁体   English

C反汇编到ARMv6:Dot(。)在Label之前的含义

[英]C Disassembly to ARMv6: Meaning of Dot (.) Before a Label

I disassembled a C program to see how structs were created and I have a question. 我反汇编了一个C程序,看看结构是如何创建的,我有一个问题。 This is on a Raspberry PI using 这是在Raspberry PI上使用的

gcc -S -o source.s mystruct.c gcc -S -o source.s mystruct.c

To get the source. 获取来源。

Questions: 问题:

I noticed in all the programs I disassemble, there are labels .Lxx . 我注意到在我拆解的所有程序中都有标签.Lxx What's the difference between a label with a . 带有标签的标签有什么区别. in front and a label without one? 在前面和没有一个标签? I guess I'm confused because directives have a '.', like .data . 我想我很困惑,因为指令有一个'。',就像.data

Code

typedef struct {
    int x;
    int y;
} point;

int main( int argc, char *argv[] ){
    point p = { 1, 2 };

    p.x = 2;
    p.x = p.x - p.y;

    return p.x;
}

Disassemble to 拆卸到

        .arch armv6
        .eabi_attribute 27, 3
        .eabi_attribute 28, 1
        .fpu vfp
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 2
        .eabi_attribute 30, 6
        .eabi_attribute 34, 1
        .eabi_attribute 18, 4
        .file   "struct.c"
        .section        .rodata
        .align  2
.LC0:
        .word   1
        .word   2
        .text
        .align  2
        .global main
        .type   main, %function
main:
        @ args = 0, pretend = 0, frame = 16
        @ frame_needed = 1, uses_anonymous_args = 0
        @ link register save eliminated.
        str     fp, [sp, #-4]!
        add     fp, sp, #0
        sub     sp, sp, #20
        str     r0, [fp, #-16]
        str     r1, [fp, #-20]
        ldr     r2, .L3
        sub     r3, fp, #12
        ldmia   r2, {r0, r1}
        stmia   r3, {r0, r1}
        mov     r3, #3
        str     r3, [fp, #-12]
        mov     r3, #0
        mov     r0, r3
        add     sp, fp, #0
        ldmfd   sp!, {fp}
        bx      lr
.L4:
        .align  2
.L3:
        .word   .LC0
        .size   main, .-main
        .ident  "GCC: (Debian 4.7.2-5+rpi1) 4.7.2"
        .section        .note.GNU-stack,"",%progbits

The .L prefix denotes a local symbol , which is a symbol visible only in that source file (these symbol are not exported to the .o file unless you specify a special option to the assembler). .L前缀表示本地符号 ,它是仅在该源文件中可见的符号(除非您为汇编程序指定了特殊选项,否则这些符号不会导出到.o文件中)。

You can tell they are labels because the line ends with : ; 您可以告诉它们是标签,因为该行以: directives do not. 指令没有。

For more information, see the GCC Symbol Names documentation: 有关更多信息,请参阅GCC 符号名称文档:

A local symbol is any symbol beginning with certain local label prefixes. 本地符号是以某些本地标签前缀开头的任何符号。 By default, the local label prefix is .L for ELF systems or L for traditional a.out systems, but each target may have its own set of local label prefixes. 默认情况下,ELF系统的本地标签前缀为.L ,传统的a.out系统为L ,但每个目标可能有自己的一组本地标签前缀。 On the HPPA local symbols begin with L$ . 在HPPA上,本地符号以L$开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM