android核心編譯劄記

來源:互聯網
上載者:User

   1.核心編譯完成後可以產生 arch/arm/boot/compressed/vmlinux, arch/arm/boot/Image, arch/arm/boot/zImage

其中vmlinux 是一個elf格式的檔案,Image為核心映像檔案,而zImage為核心的一種映像壓縮檔,Image大約為4M,而zImage不到2M。zImage 是ARM Linux常用的一種壓縮映像檔案,它是在zImage之前加上一個長度為0x40的“頭”,說明 這個映像檔案的類型、載入位置、產生時間、大小等資訊。

 

 2.他們之間的關係:

    LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  AS      arch/arm/boot/compressed/head.o
  GZIP    arch/arm/boot/compressed/piggy.gz
  AS      arch/arm/boot/compressed/piggy.o
  CC      arch/arm/boot/compressed/misc.o
  AS      arch/arm/boot/compressed/head-xscale.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage

 

 3.objcopy是GNU工具 + 生產力程式,objcopy的作用是拷貝一個目標檔案的內容到另一個目標檔案中。用於將object的部分獲全部內容拷貝到另一個object,從而可以實現格式的變換。

 

 

objcopy可用用於將檔案轉換成S-record格式或者raw二進位格式。

例如,

         xxxx-elf-objcopy –O srec test.o test.s19

則將test.o轉換成s-record檔案中。通常涉及到text段。

         xxxx-elf-objcopy –O binary test.o test.bin

則將test.o轉換成raw binary檔案格式。

       當將object檔案轉換成raw binary格式時,通常將去除掉symbols和relocation資訊。在產生s-record過程中,有時需要用選項“-S”,“-R”去除掉binary檔案,s-record檔案不需要的相應資訊。


4.mkimage工具,這個工具可以用來製作不壓縮或者壓縮的多種可啟動映象檔案。 

mkimage在製作映象檔案的時候,是在原來的可執行映象檔案的前面加上一個0x40位元組的頭,記錄參數所指定的資訊,這樣uboot才能識別這個映象是針對哪個CPU體繫結構的,哪個OS的,哪種類型,載入記憶體中的哪個位置, 進入點在記憶體的那個位置以及映象名是什麼
root@Glym:/tftpboot# ./mkimage
Usage: ./mkimage -l image
-l ==> list image header information
./mkimage -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-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)
參數說明:
-A 指定CPU的體繫結構:
取值 表示的體繫結構
alpha Alpha 
arm A RM 
x86 Intel x86
ia64 IA64
mips MIPS
mips64 MIPS 64 Bit
ppc PowerPC
s390 IBM S390
sh SuperH
sparc SPARC
sparc64 SPARC 64 Bit
m68k MC68000
-O 指定作業系統類型,可以取以下值:
openbsd、netbsd、freebsd、4_4bsd、linux、svr4、esix、solaris、irix、sco、dell、ncr、lynxos、vxworks、psos、qnx、u-boot、rtems、artos
-T 指定映象類型,可以取以下值:
standalone、kernel、ramdisk、multi、firmware、、filesystem
-C 指定映象壓縮方式,可以取以下值:
none 不壓縮
gzip 用gzip的壓縮方式
bzip2 用bzip2的壓縮方式
-a 指定映象在記憶體中的載入地址,映象下載到記憶體中時,要按照用mkimage製作映象時,這個參數所指定的地址值來下載
-e 指定映象啟動並執行進入點地址,這個地址就是-a參數指定的值加上0x40(因為前面有個mkimage添加的0x40個位元組的頭)
-n 指定映象名
-d 指定製作映象的源檔案

 

 

相關文章

聯繫我們

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