Chinaunix

标题: 讨论:vmlinux.bin、bzImage、zImage的区别 [打印本页]

作者: surf_081    时间: 2012-06-12 16:09
标题: 讨论:vmlinux.bin、bzImage、zImage的区别
据我所了解:

vmlinux.bin由vmlinux经gzip压缩后,与压缩函数、启动代码一起链接而成

bzImage由vmlinux.bin与setup.bin等文件build而成

zImage是小于640K的压缩核,不知与bzImage是否有其他区别?

我在两个嵌入式项目中发现一些疑问:
1、基于arm平台时编译内核用的是zImage
2、基于misps平台编译内核用的是vmlinux.bin,该平台好像不支持bzImage
3、我在x86的PC上测试,make后生成了vmlinux.bin、setup.bin、bzImage

请教:1中的zImage与3中的bzImage有何区别,是不是嵌入式中一般不用bzImage呢?那bzImage的存在意义何在?
         另外,2中的vmlinux.bin与3中的vmlinux.bin实质一样吗?

请大家发表一下自己的见解
作者: daniel_kohler    时间: 2012-06-13 14:15
本帖最后由 daniel_kohler 于 2012-06-13 14:16 编辑

回复 1# surf_081


vmlinux

This is the Linux kernel in an statically linked executable file format. Generally, you don't have to worry about this file, it's just a intermediate step in the boot procedure.

The raw vmlinux file may be useful for debugging purposes.

vmlinux.bin

The same as vmlinux, but in a binary file format.

vmlinuz

The vmlinux file usually gets compressed with zlib. Since 2.6.30 LZMA and bzip2 are also available. By adding further boot and decompression capabilities to vmlinuz, the image can be used to boot a system with the vmlinux kernel. The compression of vmlinux can occur with zImage or bzImage.

The function decompress_kernel() handles the decompression of vmlinuz at bootup, a message indicates this:

Decompressing Linux... done
Booting the kernel.

zImage (make zImage)

This is the old format for small kernels (compressed, below 512KB). At boot, this image gets loaded low in memory (the first 640KB of the RAM).

bzImage (make bzImage)

The big zImage (this has nothing to do with bzip2), was created while the kernel grew and handles bigger images (compressed, over 512KB). The image gets loaded high in memory (above 1MB RAM). As today's kernels are way over 512KB, this is usually the preferred way.


作者: firocu    时间: 2013-02-19 18:13
楼上的出处是哪里?
vmlinux的解释,不能理解。求赐教!


回复 2# daniel_kohler


   
作者: daniel_kohler    时间: 2013-02-20 20:00
回复 3# firocu


    http://en.wikipedia.org/wiki/Vmlinux
作者: wsw1wsw2    时间: 2013-02-26 14:15
vmlinux 是kernel中object文件link后的文件,注意是个ELF文件。
vmlinux.bin 看生成这个文件的命令,如果是objcopy生成的bin文件则这个文件就是vmlinux这个ELF文件的内存影像。也就说把这个文件载入到硬件系统的某个地址,它就可以启动了。(这个地址一般是它的链接地址)
zImage个bzImage都是把vmlinux.bin压缩后,再加上一个头,这个头负责解压缩vmlinux.bin文件。这与这个头怎么写,那就要和bootloader配合了,因为涉及到bootloader怎么传递命令行参数之类的。一般uboot会有一个工具mkimge之类的直接生成zImage或者uImage。bzimage就简单了,看看kernel的x86 boot的文档,载入这个bzimage后还得在制定的地方填入许多信息,比如命令行参数initrd的地址等等。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2