《Linux核心完全剖析-基於0.12核心》第四章的簡單多任務核心Makefile的注釋

來源:互聯網
上載者:User
趙炯老師的《Linux核心完全剖析-基於0.12核心》第四章的簡單多任務核心,也就是不斷輸出AAAAABBBBB的那個最簡單的核心樣本,源碼部分書中解釋的很清楚了,但是如何編譯組織檔案就要看makefile。現在將其注釋如下,如有不當之處,希望大家指教。
# Makefile for the simple example kernel.

#boot.s是用as86和ld86編譯連結

#head.s是用gcc,這點與Linux0.12不同
AS86        =as86 -0 -a

LD86        =ld86 -0

AS        =gas

LD        =gld

LDFLAGS        =-s -x -M


all:        Image


Image: boot system
        #dd為Unix標準命令,bs表示一次讀寫位元組數,if=input file,of=outputfile,

        #skip為跳過輸入檔案的bs開始讀取,seek為跳過輸出檔案的bs處開始寫入。

        

        #跳過boot.s的頭32個位元組,即跳過Minix 二進位首部資訊32位元組,輸入在第一個扇區,即開機磁區512位元組
        dd bs=32 if=boot of=Image skip=1
        
        #跳過1024(2*512) 位元組gcc首部,將剩餘複製在第二扇區,即從512位元組開始

        dd bs=512 if=system of=Image skip=2 seek=1 

        sync


disk: Image
#Linux下/dev/fd0 是第一個軟碟機,這條指令將新開機檔案Image寫入/dev/fd0

        dd bs=8192 if=Image of=/dev/fd0

        sync;sync;sync


head.o: head.s

# > System.map 是為-M選項服務的,表示gld需要將串連映像重新導向在System.map檔案中

system:        head.o 

        $(LD) $(LDFLAGS) head.o  -o system > System.map


boot:        boot.s

        $(AS86) -o boot.o boot.s

        $(LD86) -s -o boot boot.o


clean:

        rm -f Image System.map core boot *.o system
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.