Chapter 7 Linking——1(CSAPP讀書筆記)

來源:互聯網
上載者:User

 
Static linking
Object fileRelocatable object fileExecutable object fileShared object file: A special type of relocatable object file
現在的類unix系統主要使用的object file 類型為ELF(Unix Executable and Linkable Format)。此檔案類型中,標頭檔的主要section是這樣的:

需要注意的主要是.text,.data,.bss三個段。其中,在c語言obj檔案的連結過程中,Linker僅僅關心全域變數,局部變數交給程式運行時的stack進行管理。還需注意的部分是Local linker symbol != Local program symbol可以說二者有本質上的區別。在對於各個symbol所佔的section判斷時,是不是可以簡單的看做:Local program symbol不在.symtab中,Global symbol需要區分是不是extern,是不是初始化的。初始化的符號存在於.data段中,未初始化的存在於.bss段中。P.S. .bss可以方便的記憶為 best save space ( ̄ー ̄)另外c中的static關鍵字可以理解為是該檔案對外部將此變數設定的封裝,即所謂的存取權限(public,private......神馬的),一個c檔案可以看作一個單獨的模組。To be continued......

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.