X86 程序集:.text.startup 节和.text 节有什么区别 [英] X86 assembly: What is the difference between .text.startup section and .text section
问题描述
.file "test-instr.c"
.text
.Ltext0:
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Hum?"
.LC1:
.string "Looks like a zero to me!"
.LC2:
.string "A non-zero value? How quaint!"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
/* --- trampoline malloc shm space begin --- */
.align 4
.section .data
shmSize: .quad 8 * 4 * 0x10000
.global shmptr
shmptr: .quad 0
.section .text
.extern malloc
movq (shmSize), %rdi
call malloc
movq %rax, (shmptr)
/* --- trampoline malloc shm spacd end --- */
.LFB52:
.file 1 "test-instr.c"
.loc 1 21 0
.cfi_startproc
.LVL0:
subq $24, %rsp
.cfi_def_cfa_offset 32
.LBB10:
.LBB11:
.file 2 "/usr/include/x86_64-linux-gnu/bits/unistd.h"
.loc 2 44 0
xorl %edi, %edi
.LVL1:
movl $8, %edx
movq %rsp, %rsi
.LVL2:
movq %rax, %rbx
.LBE11:
.LBE10:
.loc 1 21 0
movq %fs:40, %rax
movq %rax, 8(%rsp)
xorl %eax, %eax
.LVL3:
.LBB13:
.LBB12:
.loc 2 44 0
call read@PLT
.LVL4:
.LBE12:
.LBE13:
.loc 1 25 0
testq %rax, %rax
jle .L8
.loc 1 30 0
cmpb $48, (%rsp)
je .L9
.LVL5:
.LBB14:
.LBB15:
.file 3 "/usr/include/x86_64-linux-gnu/bits/stdio2.h"
.loc 3 104 0
leaq .LC2(%rip), %rdi
call puts@PLT
.LVL6:
.L4:
.LBE15:
.LBE14:
.loc 1 35 0
xorl %edi, %edi
call exit@PLT
.LVL7:
.L9:
.LBB16:
.LBB17:
.loc 3 104 0
leaq .LC1(%rip), %rdi
call puts@PLT
.LVL8:
jmp .L4
.LVL9:
.L8:
.LBE17:
.LBE16:
.LBB18:
.LBB19:
leaq .LC0(%rip), %rdi
call puts@PLT
.LVL10:
.LBE19:
.LBE18:
.loc 1 27 0
movl $1, %edi
call exit@PLT
.LVL11:
.cfi_endproc
.LFE52:
.size main, .-main
.text
.Letext0:
.file 4 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h"
.file 5 "/usr/include/x86_64-linux-gnu/bits/types.h"
.file 6 "/usr/include/x86_64-linux-gnu/bits/libio.h"
.file 7 "/usr/include/stdio.h"
.file 8 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h"
.file 9 "/usr/include/unistd.h"
.file 10 "/usr/include/x86_64-linux-gnu/bits/getopt_core.h"
.file 11 "<built-in>"
.file 12 "/usr/include/stdlib.h"
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x5bc
.value 0x4
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF73
.byte 0xc
.long .LASF74
.long .LASF75
.long .Ldebug_ranges0+0x30
.quad 0
.long .Ldebug_line0
.uleb128 0x2
.long .LASF7
.byte 0x4
.byte 0xd8
.long 0x34
.uleb128 0x3
.byte 0x8
.byte 0x7
.long .LASF0
.uleb128 0x3
.byte 0x1
.byte 0x8
.long .LASF1
.uleb128 0x3
.byte 0x2
.byte 0x7
.long .LASF2
.uleb128 0x3
.byte 0x4
.byte 0x7
.long .LASF3
.uleb128 0x3
.byte 0x1
.byte 0x6
.long .LASF4
.uleb128 0x3
.byte 0x2
.byte 0x5
.long .LASF5
.uleb128 0x4
.byte 0x4
.byte 0x5
.string "int"
.uleb128 0x3
.byte 0x8
.byte 0x5
.long .LASF6
.uleb128 0x2
.long .LASF8
.byte 0x5
.byte 0x8c
.long 0x65
.uleb128 0x2
.long .LASF9
.byte 0x5
.byte 0x8d
.long 0x65
.uleb128 0x5
.byte 0x8
.uleb128 0x2
.long .LASF10
.byte 0x5
.byte 0xb5
.long 0x65
.uleb128 0x6
.byte 0x8
.long 0x95
.uleb128 0x3
.byte 0x1
.byte 0x6
.long .LASF11
.uleb128 0x7
.long 0x95
.uleb128 0x8
.long .LASF41
.byte 0xd8
.byte 0x6
.byte 0xf5
.long 0x221
.uleb128 0x9
.long .LASF12
.byte 0x6
.byte 0xf6
.long 0x5e
.byte 0
.uleb128 0x9
.long .LASF13
.byte 0x6
.byte 0xfb
.long 0x8f
.byte 0x8
.uleb128 0x9
.long .LASF14
.byte 0x6
.byte 0xfc
.long 0x8f
.byte 0x10
.uleb128 0x9
.long .LASF15
.byte 0x6
.byte 0xfd
.long 0x8f
.byte 0x18
.uleb128 0x9
.long .LASF16
.byte 0x6
.byte 0xfe
.long 0x8f
.byte 0x20
.uleb128 0x9
.long .LASF17
.byte 0x6
.byte 0xff
.long 0x8f
.byte 0x28
.uleb128 0xa
.long .LASF18
.byte 0x6
.value 0x100
.long 0x8f
.byte 0x30
.uleb128 0xa
.long .LASF19
.byte 0x6
.value 0x101
.long 0x8f
.byte 0x38
.uleb128 0xa
.long .LASF20
.byte 0x6
.value 0x102
.long 0x8f
.byte 0x40
.uleb128 0xa
.long .LASF21
.byte 0x6
.value 0x104
.long 0x8f
.byte 0x48
.uleb128 0xa
.long .LASF22
.byte 0x6
.value 0x105
.long 0x8f
.byte 0x50
.uleb128 0xa
.long .LASF23
.byte 0x6
.value 0x106
.long 0x8f
.byte 0x58
.uleb128 0xa
.long .LASF24
.byte 0x6
.value 0x108
.long 0x259
.byte 0x60
.uleb128 0xa
.long .LASF25
.byte 0x6
.value 0x10a
.long 0x25f
.byte 0x68
.uleb128 0xa
.long .LASF26
.byte 0x6
.value 0x10c
.long 0x5e
.byte 0x70
.uleb128 0xa
.long .LASF27
.byte 0x6
.value 0x110
.long 0x5e
.byte 0x74
.uleb128 0xa
.long .LASF28
.byte 0x6
.value 0x112
.long 0x6c
.byte 0x78
.uleb128 0xa
.long .LASF29
.byte 0x6
.value 0x116
.long 0x42
.byte 0x80
.uleb128 0xa
.long .LASF30
.byte 0x6
.value 0x117
.long 0x50
.byte 0x82
.uleb128 0xa
.long .LASF31
.byte 0x6
.value 0x118
.long 0x265
.byte 0x83
.uleb128 0xa
.long .LASF32
.byte 0x6
.value 0x11c
.long 0x275
.byte 0x88
.uleb128 0xa
.long .LASF33
.byte 0x6
.value 0x125
.long 0x77
.byte 0x90
.uleb128 0xa
.long .LASF34
.byte 0x6
.value 0x12d
.long 0x82
.byte 0x98
.uleb128 0xa
.long .LASF35
.byte 0x6
.value 0x12e
.long 0x82
.byte 0xa0
.uleb128 0xa
.long .LASF36
.byte 0x6
.value 0x12f
.long 0x82
.byte 0xa8
.uleb128 0xa
.long .LASF37
.byte 0x6
.value 0x130
.long 0x82
.byte 0xb0
.uleb128 0xa
.long .LASF38
.byte 0x6
.value 0x132
.long 0x29
.byte 0xb8
.uleb128 0xa
.long .LASF39
.byte 0x6
.value 0x133
.long 0x5e
.byte 0xc0
.uleb128 0xa
.long .LASF40
.byte 0x6
.value 0x135
.long 0x27b
.byte 0xc4
.byte 0
.uleb128 0xb
.long .LASF76
.byte 0x6
.byte 0x9a
.uleb128 0x8
.long .LASF42
.byte 0x18
.byte 0x6
.byte 0xa0
.long 0x259
.uleb128 0x9
.long .LASF43
.byte 0x6
.byte 0xa1
.long 0x259
.byte 0
.uleb128 0x9
.long .LASF44
.byte 0x6
.byte 0xa2
.long 0x25f
.byte 0x8
.uleb128 0x9
.long .LASF45
.byte 0x6
.byte 0xa6
.long 0x5e
.byte 0x10
.byte 0
.uleb128 0x6
.byte 0x8
.long 0x228
.uleb128 0x6
.byte 0x8
.long 0xa1
.uleb128 0xc
.long 0x95
.long 0x275
.uleb128 0xd
.long 0x34
.byte 0
.byte 0
.uleb128 0x6
.byte 0x8
.long 0x221
.uleb128 0xc
.long 0x95
.long 0x28b
.uleb128 0xd
.long 0x34
.byte 0x13
.byte 0
.uleb128 0xe
.long .LASF77
.uleb128 0xf
.long .LASF46
.byte 0x6
.value 0x13f
.long 0x28b
.uleb128 0xf
.long .LASF47
.byte 0x6
.value 0x140
.long 0x28b
.uleb128 0xf
.long .LASF48
.byte 0x6
.value 0x141
.long 0x28b
.uleb128 0x6
.byte 0x8
.long 0x9c
.uleb128 0x7
.long 0x2b4
.uleb128 0x10
.long 0x2b4
.uleb128 0x2
.long .LASF49
.byte 0x7
.byte 0x47
.long 0x84
.uleb128 0x11
.long .LASF50
.byte 0x7
.byte 0x87
.long 0x25f
.uleb128 0x11
.long .LASF51
.byte 0x7
.byte 0x88
.long 0x25f
.uleb128 0x11
.long .LASF52
.byte 0x7
.byte 0x89
.long 0x25f
.uleb128 0x11
.long .LASF53
.byte 0x8
.byte 0x1a
.long 0x5e
.uleb128 0xc
.long 0x2ba
.long 0x306
.uleb128 0x12
.byte 0
.uleb128 0x7
.long 0x2fb
.uleb128 0x11
.long .LASF54
.byte 0x8
.byte 0x1b
.long 0x306
.uleb128 0x3
.byte 0x8
.byte 0x5
.long .LASF55
.uleb128 0x3
.byte 0x8
.byte 0x7
.long .LASF56
.uleb128 0xc
.long 0x95
.long 0x334
.uleb128 0xd
.long 0x34
.byte 0x7
.byte 0
.uleb128 0xf
.long .LASF57
.byte 0x9
.value 0x222
.long 0x340
.uleb128 0x6
.byte 0x8
.long 0x8f
.uleb128 0x11
.long .LASF58
.byte 0xa
.byte 0x24
.long 0x8f
.uleb128 0x11
.long .LASF59
.byte 0xa
.byte 0x32
.long 0x5e
.uleb128 0x11
.long .LASF60
.byte 0xa
.byte 0x37
.long 0x5e
.uleb128 0x11
.long .LASF61
.byte 0xa
.byte 0x3b
.long 0x5e
.uleb128 0x13
.long .LASF78
.byte 0x1
.byte 0x15
.long 0x5e
.quad .LFB52
.quad .LFE52-.LFB52
.uleb128 0x1
.byte 0x9c
.long 0x4fb
.uleb128 0x14
.long .LASF62
.byte 0x1
.byte 0x15
.long 0x5e
.long .LLST0
.uleb128 0x14
.long .LASF63
.byte 0x1
.byte 0x15
.long 0x340
.long .LLST1
.uleb128 0x15
.string "buf"
.byte 0x1
.byte 0x17
.long 0x324
.uleb128 0x2
.byte 0x91
.sleb128 -32
.uleb128 0x16
.long 0x4fb
.quad .LBB10
.long .Ldebug_ranges0+0
.byte 0x1
.byte 0x19
.long 0x410
.uleb128 0x17
.long 0x521
.long .LLST2
.uleb128 0x17
.long 0x516
.long .LLST3
.uleb128 0x17
.long 0x50b
.long .LLST4
.uleb128 0x18
.quad .LVL4
.long 0x54a
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x1
.byte 0x30
.uleb128 0x19
.uleb128 0x1
.byte 0x54
.uleb128 0x2
.byte 0x77
.sleb128 0
.uleb128 0x19
.uleb128 0x1
.byte 0x51
.uleb128 0x1
.byte 0x38
.byte 0
.byte 0
.uleb128 0x1a
.long 0x52d
.quad .LBB14
.quad .LBE14-.LBB14
.byte 0x1
.byte 0x21
.long 0x450
.uleb128 0x17
.long 0x53d
.long .LLST5
.uleb128 0x18
.quad .LVL6
.long 0x57c
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x9
.byte 0x3
.quad .LC2
.byte 0
.byte 0
.uleb128 0x1a
.long 0x52d
.quad .LBB16
.quad .LBE16-.LBB16
.byte 0x1
.byte 0x1f
.long 0x490
.uleb128 0x17
.long 0x53d
.long .LLST6
.uleb128 0x18
.quad .LVL8
.long 0x57c
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x9
.byte 0x3
.quad .LC1
.byte 0
.byte 0
.uleb128 0x1a
.long 0x52d
.quad .LBB18
.quad .LBE18-.LBB18
.byte 0x1
.byte 0x1a
.long 0x4d0
.uleb128 0x17
.long 0x53d
.long .LLST7
.uleb128 0x18
.quad .LVL10
.long 0x57c
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x9
.byte 0x3
.quad .LC0
.byte 0
.byte 0
.uleb128 0x1b
.quad .LVL7
.long 0x5b3
.long 0x4e7
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x1
.byte 0x30
.byte 0
.uleb128 0x18
.quad .LVL11
.long 0x5b3
.uleb128 0x19
.uleb128 0x1
.byte 0x55
.uleb128 0x1
.byte 0x31
.byte 0
.byte 0
.uleb128 0x1c
.long .LASF67
.byte 0x2
.byte 0x22
.long 0x2c4
.byte 0x3
.long 0x52d
.uleb128 0x1d
.long .LASF64
.byte 0x2
.byte 0x22
.long 0x5e
.uleb128 0x1d
.long .LASF65
.byte 0x2
.byte 0x22
.long 0x82
.uleb128 0x1d
.long .LASF66
.byte 0x2
.byte 0x22
.long 0x29
.byte 0
.uleb128 0x1c
.long .LASF68
.byte 0x3
.byte 0x66
.long 0x5e
.byte 0x3
.long 0x54a
.uleb128 0x1d
.long .LASF69
.byte 0x3
.byte 0x66
.long 0x2bf
.uleb128 0x1e
.byte 0
.uleb128 0x1f
.long .LASF67
.long .LASF71
.byte 0x2
.byte 0x19
.long .LASF67
.uleb128 0x20
.uleb128 0x21
.byte 0x9e
.uleb128 0x1f
.byte 0x41
.byte 0x20
.byte 0x6e
.byte 0x6f
.byte 0x6e
.byte 0x2d
.byte 0x7a
.byte 0x65
.byte 0x72
.byte 0x6f
.byte 0x20
.byte 0x76
.byte 0x61
.byte 0x6c
.byte 0x75
.byte 0x65
.byte 0x3f
.byte 0x20
.byte 0x48
.byte 0x6f
.byte 0x77
.byte 0x20
.byte 0x71
.byte 0x75
.byte 0x61
.byte 0x69
.byte 0x6e
.byte 0x74
.byte 0x21
.byte 0xa
.byte 0
.uleb128 0x1f
.long .LASF70
.long .LASF72
.byte 0xb
.byte 0
.long .LASF70
.uleb128 0x20
.uleb128 0x1c
.byte 0x9e
.uleb128 0x1a
.byte 0x4c
.byte 0x6f
.byte 0x6f
.byte 0x6b
.byte 0x73
.byte 0x20
.byte 0x6c
.byte 0x69
.byte 0x6b
.byte 0x65
.byte 0x20
.byte 0x61
.byte 0x20
.byte 0x7a
.byte 0x65
.byte 0x72
.byte 0x6f
.byte 0x20
.byte 0x74
.byte 0x6f
.byte 0x20
.byte 0x6d
.byte 0x65
.byte 0x21
.byte 0xa
.byte 0
.uleb128 0x20
.uleb128 0x8
.byte 0x9e
.uleb128 0x6
.byte 0x48
.byte 0x75
.byte 0x6d
.byte 0x3f
.byte 0xa
.byte 0
.uleb128 0x21
.long .LASF79
.long .LASF79
.byte 0xc
.value 0x266
.byte 0
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.uleb128 0x55
.uleb128 0x17
.uleb128 0x11
.uleb128 0x1
.uleb128 0x10
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x2
.uleb128 0x16
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x3
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.byte 0
.byte 0
.uleb128 0x4
.uleb128 0x24
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.uleb128 0x3
.uleb128 0x8
.byte 0
.byte 0
.uleb128 0x5
.uleb128 0xf
.byte 0
.uleb128 0xb
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0x6
.uleb128 0xf
.byte 0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x7
.uleb128 0x26
.byte 0
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x8
.uleb128 0x13
.byte 0x1
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x9
.uleb128 0xd
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xa
.uleb128 0xd
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xb
.uleb128 0x16
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xc
.uleb128 0x1
.byte 0x1
.uleb128 0x49
.uleb128 0x13
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0xd
.uleb128 0x21
.byte 0
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2f
.uleb128 0xb
.byte 0
.byte 0
.uleb128 0xe
.uleb128 0x13
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3c
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0xf
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.uleb128 0x49
.uleb128 0x13
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3c
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0x10
.uleb128 0x37
.byte 0
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x11
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3c
.uleb128 0x19
.byte 0
.byte 0
.uleb128 0x12
.uleb128 0x21
.byte 0
.byte 0
.byte 0
.uleb128 0x13
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x7
.uleb128 0x40
.uleb128 0x18
.uleb128 0x2117
.uleb128 0x19
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x14
.uleb128 0x5
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x15
.uleb128 0x34
.byte 0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x18
.byte 0
.byte 0
.uleb128 0x16
.uleb128 0x1d
.byte 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x52
.uleb128 0x1
.uleb128 0x55
.uleb128 0x17
.uleb128 0x58
.uleb128 0xb
.uleb128 0x59
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x17
.uleb128 0x5
.byte 0
.uleb128 0x31
.uleb128 0x13
.uleb128 0x2
.uleb128 0x17
.byte 0
.byte 0
.uleb128 0x18
.uleb128 0x4109
.byte 0x1
.uleb128 0x11
.uleb128 0x1
.uleb128 0x31
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x19
.uleb128 0x410a
.byte 0
.uleb128 0x2
.uleb128 0x18
.uleb128 0x2111
.uleb128 0x18
.byte 0
.byte 0
.uleb128 0x1a
.uleb128 0x1d
.byte 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x7
.uleb128 0x58
.uleb128 0xb
.uleb128 0x59
.uleb128 0xb
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x1b
.uleb128 0x4109
.byte 0x1
.uleb128 0x11
.uleb128 0x1
.uleb128 0x31
.uleb128 0x13
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x1c
.uleb128 0x2e
.byte 0x1
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0x19
.uleb128 0x49
.uleb128 0x13
.uleb128 0x20
.uleb128 0xb
.uleb128 0x34
.uleb128 0x19
.uleb128 0x1
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x1d
.uleb128 0x5
.byte 0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0
.byte 0
.uleb128 0x1e
.uleb128 0x18
.byte 0
.byte 0
.byte 0
.uleb128 0x1f
.uleb128 0x2e
.byte 0
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3c
.uleb128 0x19
.uleb128 0x6e
.uleb128 0xe
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x6e
.uleb128 0xe
.byte 0
.byte 0
.uleb128 0x20
.uleb128 0x36
.byte 0
.uleb128 0x2
.uleb128 0x18
.byte 0
.byte 0
.uleb128 0x21
.uleb128 0x2e
.byte 0
.uleb128 0x3f
.uleb128 0x19
.uleb128 0x3c
.uleb128 0x19
.uleb128 0x6e
.uleb128 0xe
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.byte 0
.byte 0
.byte 0
.section .debug_loc,"",@progbits
.Ldebug_loc0:
.LLST0:
.quad .LVL0
.quad .LVL1
.value 0x1
.byte 0x55
.quad .LVL1
.quad .LFE52
.value 0x4
.byte 0xf3
.uleb128 0x1
.byte 0x55
.byte 0x9f
.quad 0
.quad 0
.LLST1:
.quad .LVL0
.quad .LVL2
.value 0x1
.byte 0x54
.quad .LVL2
.quad .LFE52
.value 0x4
.byte 0xf3
.uleb128 0x1
.byte 0x54
.byte 0x9f
.quad 0
.quad 0
.LLST2:
.quad .LVL3
.quad .LVL4
.value 0x2
.byte 0x38
.byte 0x9f
.quad 0
.quad 0
.LLST3:
.quad .LVL3
.quad .LVL4-1
.value 0x1
.byte 0x54
.quad .LVL4-1
.quad .LVL4
.value 0x1
.byte 0x57
.quad 0
.quad 0
.LLST4:
.quad .LVL3
.quad .LVL4
.value 0x2
.byte 0x30
.byte 0x9f
.quad 0
.quad 0
.LLST5:
.quad .LVL5
.quad .LVL6
.value 0x6
.byte 0xf2
.long .Ldebug_info0+1369
.sleb128 0
.quad 0
.quad 0
.LLST6:
.quad .LVL7
.quad .LVL9
.value 0x6
.byte 0xf2
.long .Ldebug_info0+1419
.sleb128 0
.quad 0
.quad 0
.LLST7:
.quad .LVL9
.quad .LVL10
.value 0x6
.byte 0xf2
.long .Ldebug_info0+1449
.sleb128 0
.quad 0
.quad 0
.section .debug_aranges,"",@progbits
.long 0x2c
.value 0x2
.long .Ldebug_info0
.byte 0x8
.byte 0
.value 0
.value 0
.quad .LFB52
.quad .LFE52-.LFB52
.quad 0
.quad 0
.section .debug_ranges,"",@progbits
.Ldebug_ranges0:
.quad .LBB10
.quad .LBE10
.quad .LBB13
.quad .LBE13
.quad 0
.quad 0
.quad .LFB52
.quad .LFE52
.quad 0
.quad 0
.section .debug_line,"",@progbits
.Ldebug_line0:
.section .debug_str,"MS",@progbits,1
.LASF59:
.string "optind"
.LASF58:
.string "optarg"
.LASF72:
.string "__builtin_puts"
.LASF41:
.string "_IO_FILE"
.LASF53:
.string "sys_nerr"
.LASF23:
.string "_IO_save_end"
.LASF5:
.string "short int"
.LASF7:
.string "size_t"
.LASF33:
.string "_offset"
.LASF64:
.string "__fd"
.LASF17:
.string "_IO_write_ptr"
.LASF12:
.string "_flags"
.LASF47:
.string "_IO_2_1_stdout_"
.LASF49:
.string "ssize_t"
.LASF57:
.string "__environ"
.LASF24:
.string "_markers"
.LASF14:
.string "_IO_read_end"
.LASF65:
.string "__buf"
.LASF52:
.string "stderr"
.LASF55:
.string "long long int"
.LASF10:
.string "__ssize_t"
.LASF32:
.string "_lock"
.LASF73:
.string "GNU C11 7.5.0 -mtune=generic -march=x86-64 -g -g -g -O0 -O3 -funroll-loops -fstack-protector-strong"
.LASF6:
.string "long int"
.LASF68:
.string "printf"
.LASF29:
.string "_cur_column"
.LASF48:
.string "_IO_2_1_stderr_"
.LASF77:
.string "_IO_FILE_plus"
.LASF45:
.string "_pos"
.LASF63:
.string "argv"
.LASF79:
.string "exit"
.LASF44:
.string "_sbuf"
.LASF28:
.string "_old_offset"
.LASF1:
.string "unsigned char"
.LASF62:
.string "argc"
.LASF67:
.string "read"
.LASF4:
.string "signed char"
.LASF56:
.string "long long unsigned int"
.LASF46:
.string "_IO_2_1_stdin_"
.LASF3:
.string "unsigned int"
.LASF42:
.string "_IO_marker"
.LASF31:
.string "_shortbuf"
.LASF70:
.string "puts"
.LASF16:
.string "_IO_write_base"
.LASF40:
.string "_unused2"
.LASF60:
.string "opterr"
.LASF20:
.string "_IO_buf_end"
.LASF11:
.string "char"
.LASF78:
.string "main"
.LASF43:
.string "_next"
.LASF34:
.string "__pad1"
.LASF35:
.string "__pad2"
.LASF36:
.string "__pad3"
.LASF37:
.string "__pad4"
.LASF38:
.string "__pad5"
.LASF2:
.string "short unsigned int"
.LASF69:
.string "__fmt"
.LASF0:
.string "long unsigned int"
.LASF18:
.string "_IO_write_end"
.LASF9:
.string "__off64_t"
.LASF26:
.string "_fileno"
.LASF66:
.string "__nbytes"
.LASF25:
.string "_chain"
.LASF8:
.string "__off_t"
.LASF75:
.string "/home/syacer/Desktop/afl-2.52b"
.LASF22:
.string "_IO_backup_base"
.LASF50:
.string "stdin"
.LASF19:
.string "_IO_buf_base"
.LASF27:
.string "_flags2"
.LASF39:
.string "_mode"
.LASF15:
.string "_IO_read_base"
.LASF30:
.string "_vtable_offset"
.LASF74:
.string "test-instr.c"
.LASF21:
.string "_IO_save_base"
.LASF54:
.string "sys_errlist"
.LASF61:
.string "optopt"
.LASF71:
.string "__read_alias"
.LASF13:
.string "_IO_read_ptr"
.LASF51:
.string "stdout"
.LASF76:
.string "_IO_lock_t"
.ident "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0"
.section .note.GNU-stack,"",@progbits
当我编译这段代码时,gcc 给出了这个错误:错误:main 的 .size 表达式不计算为常量
When I compile this code, gcc gives this error: Error: .size expression for main does not evaluate to a constant
如果我将 .section .text 切换到 .section .text.startup.编译器不报错.
If I switch .section .text to .section .text.startup. Compiler does not give error.
trampoline 部分被检测到 .s 文件.
The trampoline section is instrumented to the .s file.
所以我的第一个问题是 .text 和 .text.startup 之间有什么区别以及何时使用它们?
So my first question is what is the difference between .text and .text.startup and when to use them?
第二个问题是改成.text.startup有意义吗?请解释原因?
The second question is that does it make sense to change to .text.startup? Please explain the reason?
谢谢!
推荐答案
在您的仪器中切换部分时使用 .pushsection
/.popsection
. 这允许您返回到汇编程序当前在您的代码之前所在的任何部分.(GAS 手册)
GCC 使用 .text.startup
对冷"进行分组像 main
代码一样启动,所以它可以从缓存/iTLB 中驱逐,甚至在程序启动后从 RAM 中分页.和/或为了程序的实际启动阶段更好的局部性/性能,因此它可以通过从磁盘引入的页面更少来取得更多进展.(大概 _start
也进入 .text.startup
)
GCC uses .text.startup
to group "cold" startup like main
code together so it can be evicted from cache / iTLB or even paged out of RAM after the program starts up. And/or for better locality / performance of the actual startup phase of a program, so it can make more progress with fewer pages brought in from disk. (Presumably _start
also goes in .text.startup
)
它和 .text
都被链接到文本 segment (read+exec),但 .text.startup
中的所有函数都得到在一端组合在一起.
Both it and .text
get linked into the text segment (read+exec), but all functions in .text.startup
get grouped together at one end.
类似地,__attribute__((cold))
会让 GCC 知道其他函数要放在 .text.unlikely
中,它们也被组合在一起.
Similarly, __attribute__((cold))
will let GCC know about other functions to place in .text.unlikely
, which also gets grouped together.
或者使用-fprofile-generate
/-fprofile-use
PGO让GCC识别冷";函数(仅在启动时使用,仅在关闭时使用,或者在与 PGO 一起使用的非错误典型情况下根本不使用).(GCC 函数属性)
Or use -fprofile-generate
/ -fprofile-use
PGO to let GCC identify "cold" functions (either used only at startup, only at shutdown, or not at all in the non-error typical cases you used with PGO). (GCC function attributes)
要覆盖 GCC 选择的部分,请使用__attribute__((section(".text"))) int main() { ... }
这篇关于X86 程序集:.text.startup 节和.text 节有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!