CRT(C runtime library)
Microsoft Access 2016 Runtime
microsoft visual c++ runtime library
C Runtime
Visual C++ 2008 Runtime
.NET Common Language Runtime
异常向量配置
_start函数和stack初始化
cache 初始化
清除BSS
构造函数和析构函数处理
C初始化功能
调用main入口
.text
.globl _start
_start: # _start is the entry point known to the linker
xor %ebp, %ebp # effectively RBP := 0, mark the end of stack frames
mov (%rsp), %edi # get argc from the stack (implicitly zero-extended to 64-bit)
lea 8(%rsp), %rsi # take the address of argv from the stack
lea 16(%rsp,%rdi,8), %rdx # take the address of envp from the stack
xor %eax, %eax # per ABI and compatibility with icc
call main # %edi, %rsi, %rdx are the three args (of which first two are C standard) to main
mov %eax, %edi # transfer the return of main to the first argument of _exit
xor %eax, %eax # per ABI and compatibility with icc
call _exit # terminate the program
int main(int argc, char **argv)
{
return 0;
}
gcc a.c
readelf -s a.out
31: 0 FILE LOCAL DEFAULT ABS crtstuff.c
32: 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
33: 0 FUNC LOCAL DEFAULT 13 register_tm_clones
34: 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
35: 1 OBJECT LOCAL DEFAULT 24 completed.7325
36: 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fin
37: 0 FUNC LOCAL DEFAULT 13 frame_dummy
38: 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_
39: 0 FILE LOCAL DEFAULT ABS a.c
40: 0 FILE LOCAL DEFAULT ABS crtstuff.c
41: 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__
42: 0 FILE LOCAL DEFAULT ABS
43: 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
44: 0 OBJECT LOCAL DEFAULT 20 _DYNAMIC
45: 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
46: 0 NOTYPE LOCAL DEFAULT 16 __GNU_EH_FRAME_HDR
47: 0 OBJECT LOCAL DEFAULT 22 _GLOBAL_OFFSET_TABLE_
48: 0 FUNC LOCAL DEFAULT 10 _init
49: 1 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
50: 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
51: 0 NOTYPE WEAK DEFAULT 23 data_start
52: 0 NOTYPE GLOBAL DEFAULT 23 _edata
53: 0 FUNC GLOBAL HIDDEN 14 _fini
54: 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
55: 0 NOTYPE GLOBAL DEFAULT 23 __data_start
56: 0 NOTYPE WEAK DEFAULT UND __gmon_start__
57: 0 OBJECT GLOBAL HIDDEN 23 __dso_handle
58: 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used
59: 93 FUNC GLOBAL DEFAULT 13 __libc_csu_init
60: 0 NOTYPE GLOBAL DEFAULT 24 _end
61: 43 FUNC GLOBAL DEFAULT 13 _start
62: 0 NOTYPE GLOBAL DEFAULT 24 __bss_start
63: 18 FUNC GLOBAL DEFAULT 13 main
64: 0 OBJECT GLOBAL HIDDEN 23 __TMC_END__
65: 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
66: 0 FUNC WEAK DEFAULT UND __cxa_finalize@@GLIBC_2.2