我反汇编了一个C程序,看看结构是如何创建的,我有一个问题.这是在Raspberry PI上使用的
gcc -S -o source.s mystruct.c
获取来源.
我注意到在我拆卸的所有程序中都有标签.Lxx..前面的标签和没有标签的标签有什么区别?我想我很困惑,因为指令有'.',就像.data.
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;
}
Run Code Online (Sandbox Code Playgroud)
拆卸到
.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
Run Code Online (Sandbox Code Playgroud)