C運時庫

crt是“C runtimelibrary”的縮寫,其含義是“C運時庫”。

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函數。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章