歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 對uboot的start.S中的.balignl的理解

對uboot的start.S中的.balignl的理解

日期:2017/3/1 11:10:17   编辑:Linux編程

.balignl 16,0xdeadbeef

這個代碼很有意思,作者挺搞笑。剛開始的時候看不懂這個代碼是什麼意思,balignl很顯然是對齊的意思,我當時一看就知道這是16字節對齊,可是,0xdeadbeef是什麼東東?呵呵,後來我找了半天資料才知道沒什麼意思,我們可以把它用其他的代替,比如0xgoodbeef,0xgoodgirl,明白了吧。

下面我對此進行講解:

syntax:

.balign {alignment} {,fill} {,max}

Description: Word align the following code to alignment byte boundary (default=4). Fill skipped words with fill (default=0 or NOP). If the number of bytes skipped is greater than max, then don't align (default=alignment ).

alignment可以是4,8,16,32,的默認值是4

fill 就是要填充的內容

max 是一個數值,如果從當前位置開始移動到符合要求的位置所移動的地址大於max時,不采用對齊。

.balignl和.balignw是.balign的變形,前者是采用4字節填充,後者是2字節填充。

例如:

當前地址是0x0000 0001

.balignl 16,0xgoodgirl

16字節對齊,符合要求的第一個地址是0x0000 0010,可是指針移動了15位置,也就是15個字節,oxgoodgirl占4個字節,所以不填充空白區域,空白區域內容是未知的。

假如當前地址是0x0000 000e

指針移動到0x0000 0010,移動了2次,也就是2個字節,不足4個字節,空間不夠,所以也不填充,這2個字節的內容是未知的。

假如當前地址是0x0000 000c

指針移動到0x0000 0010,移到4次,也就是4個字節,正好將0xgoodgirl填充進去。

Copyright © Linux教程網 All Rights Reserved