C運行時庫除了給我們提供必要的庫函數調用(如memcpy、printf、malloc等)之外,它提供的另一個最重要的功能是爲應用程序添加啓動函數。C運行時庫啓動函數的主要功能爲進行程序的初始化,對全局變量進行賦初值,加載用戶程序的入口函數。
從給出的錯誤提示信息中還可以得知,在crt1.o中,有一個名爲“_start”的函數。現在網上找到一份crt1.o的僞代碼:
section.text:
__start:
:
init stack;
init heap;
open stdin;
open stdout;
open stderr;
:
push argv;
push argc;
call _main; (調用 main)
:
destory heap;
close stdin;
close stdout;
close stderr;
:
call __exit;
從僞代碼可以看出,在這個_start函數中,調用了main函數。