linux 内核入口地址,linux内核的加载地址和入口地址
編譯完內核之后,會產生zImage,而把它直接導入0x30008000,會出現Bad Magic Number.
查明是需要將內核加一個0x40大小的頭,由mkimage工具來添加.mkimage在編譯u-boot時在u-boot-1.1.6/tools下生成,可以為編譯的內核添加頭信息的.在bootm命令中會解析這個頭,獲得參數.zImage在編譯內核時,在arch/arm/boot目錄下生成。我們需要把zImage用mkimage工具處理一下。
mkimage參數的意義如下:
-A == set architecture to 'arch'
-O == set operating system to 'os'
-T == set image type to 'type'
-C == set compression type 'comp'
-a == set load address to 'addr' (hex)
-e == set entry point to 'ep' (hex)
-n == set image name to 'name'
-d == use image data from 'datafile'
-x == set XIP (execute in place)
首先可以把zImage拷貝到u-boot-1.1.6/tools目錄下,在此目錄下,執行如下命令:
./mkimage -n 'linux-2.6.26' -A arm -O linux -T kernel -C none -a 0x30007fc0 -e 0x30008000 -d zImage uImage
輸出信息如下:
Image Name:linux-2.6.26
Created:Tue Jul 28 18:50:26 2009
Image Type:ARM Linux Kernel Image (uncompressed)
Data Size:1655648 Bytes = 1616.84 kB = 1.58 MB
Load Address: 0x30007FC0
Entry Point:0x30008000
可以看出加載地址是0x30007fc0,而入口地址是0x30008000.
GEC2410 #tftp 30008000 uImage
TFTP from server 192.168.0.50; our IP address is 192.168.0.100
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################
done
Bytes transferred = 1655712 (1943a0 hex)
GEC2410 #bootm 30008000
## Booting image at 30008000 ...
Image Name:linux-2.6.26
Created:2009-07-2810:50:26 UTC
Image Type:ARM Linux Kernel Image (uncompressed)
Data Size:1655648 Bytes =1.6 MB
Load Address: 30007fc0
Entry Point:30008000
Verifying Checksum ... OK
OK
Starting kernel ...(卡死在這兒了)
GEC2410 #tftp 30008000 uImage
TFTP from server 192.168.0.50; our IP address is 192.168.0.100
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################
done
Bytes transferred = 1655712 (1943a0 hex)
GEC2410 #bootm 30007fc0
## Booting image at 30007fc0 ...
Bad Magic Number
GEC2410 #tftp 30007fc0 uImage
TFTP from server 192.168.0.50; our IP address is 192.168.0.100
Filename 'uImage'.
Load address: 0x30007fc0
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################
done
Bytes transferred = 1655712 (1943a0 hex)
GEC2410 #bootm 30008000
## Booting image at 30008000 ...
Bad Magic Number
GEC2410 #
GEC2410 # tftp 0x30007fc0 uImage
TFTP from server 192.168.0.50; our IP address is 192.168.0.100
Filename 'uImage'.
Load address: 0x30007fc0
Loading: #################################################################
#################################################################
#################################################################
#################################################################
################################################################
done
Bytes transferred = 1655712 (1943a0 hex)
GEC2410 #bootm 30007fc0
## Booting image at 30007fc0 ...
Image Name:linux-2.6.26
Created:2009-07-2810:50:26 UTC
Image Type:ARM Linux Kernel Image (uncompressed)
Data Size:1655648 Bytes =1.6 MB
Load Address: 30007fc0
Entry Point:30008000
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux............................................................................................................ done, booting the kernel.
………………….
(一大堆信息)
從上面可以看出,tftp下載的地址和bootm引導的地址是同一個地址,且是mkimage的參數 -a 的地址,即加載地址,而不是入口地址。
./mkimage -n 'linux-2.6.26' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage uImage
Created:Tue Jul 28 19:21:15 2009
Image Type:ARM Linux Kernel Image (uncompressed)
Data Size:1655648 Bytes = 1616.84 kB = 1.58 MB
Load Address: 0x30008000
Entry Point:0x30008000
入口地址和加載地址一樣的時候,
我在做這個嘗試的時候,導致開發板重啟……。
現在能正確引導內核啦,但是GEC2410的網卡芯片是CS8900A的芯片,要能正確的啟動Linux系統,還必須添加CS8900A的驅動……
總結
以上是生活随笔為你收集整理的linux 内核入口地址,linux内核的加载地址和入口地址的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xss挖掘思路分享_新手指南 | per
- 下一篇: linux 其他常用命令