#include <stdio.h>
int main()
{
return 0;
}
/* 确认入口地址 */
$ readelf -h 00
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x1040
Start of program headers: 64 (bytes into file)
Start of section headers: 16800 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 13
Size of section headers: 64 (bytes)
Number of section headers: 34
Section header string table index: 33
/* 反汇编 */
0000000000001040 <_start>:
1040: f3 0f 1e fa endbr64
1044: 31 ed xor %ebp,%ebp
1046: 49 89 d1 mov %rdx,%r9
1049: 5e pop %rsi
104a: 48 89 e2 mov %rsp,%rdx
104d: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
1051: 50 push %rax
1052: 54 push %rsp
1053: 4c 8d 05 56 01 00 00 lea 0x156(%rip),%r8 # 11b0 <__libc_csu_fini>
105a: 48 8d 0d df 00 00 00 lea 0xdf(%rip),%rcx # 1140 <__libc_csu_init>
1061: 48 8d 3d c1 00 00 00 lea 0xc1(%rip),%rdi # 1129 <main>
1068: ff 15 72 2f 00 00 callq *0x2f72(%rip) # 3fe0 <__libc_start_main@GLIBC_2.2.5>
106e: f4 hlt
106f: 90 nop
int main()
{
1129: f3 0f 1e fa endbr64
112d: 55 push %rbp
112e: 48 89 e5 mov %rsp,%rbp
return 0;
1131: b8 00 00 00 00 mov $0x0,%eax
}
1136: 5d pop %rbp
1137: c3 retq
1138: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
113f: 00
/* __libc_csu_init */
nm aarch64-linux-gnu/libc/usr/lib/crt1.o
0000000000000000 r $d
0000000000000030 t $d
0000000000000000 r $d
0000000000000000 t $x
U abort
0000000000000000 D __data_start
0000000000000000 W data_start
0000000000000000 R _IO_stdin_used
U __libc_csu_fini
U __libc_csu_init // U 表示没有定义的,在这里面使用了,但是在其他库中定义的符号
U __libc_start_main
U main
0000000000000000 T _start
编译时编译器与加入 crt1.o 和源程序一起生成可执行文件。
__libc_csu_init 在 libc 库里。
nm aarch64-linux-gnu/libc/usr/lib/libc.a | grep __libc_csu_init
0000000000000000 T __libc_csu_init // 符号位于代码区
00000000000000c0 T __libc_csu_fini
0000000000000000 T __libc_start_main
/* _start */
程序的真正入口