Getting uname information from a compressed kernel image

人盡茶涼 提交于 2019-12-21 00:16:43

问题


Is there a good way to extract the same information that uname does from a compressed kernel image? I want this to be able to check the dog tags of kernel sitting in dormant mtd's on an Embedded Linux system and compare it to the currently running kernel.


回答1:


For Linux image compressed with gzip, use this:

dd if=arch/arm/boot/zImage bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' arch/arm/boot/zImage | head -n 1 | cut -d ':' -f 1) | zcat | grep -a 'Linux version'

For Linux image compressed with xz, use this:

dd if=arch/arm/boot/zImage bs=1 skip=$(LC_ALL=C grep -a -b -o $'\xFD\x37\x7A\x58\x5A\x00' arch/arm/boot/zImage | head -n 1 | cut -d ':' -f 1) | xzcat | grep -a 'Linux version'

Because the image file contains data after the end of the compressed stream, you'll get an error you can ignore.

The string constant appears to be part of the frozen userspace visible kernel API:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=init/version.c;hb=HEAD#l40




回答2:


$ mkimage -l uImage

Image Name:   Linux-2.6.39
Created:      Wed Jun  6 13:49:58 2012
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3091036 Bytes = 3018.59 kB = 2.95 MB
Load Address: 80008000
Entry Point:  80008000


来源:https://stackoverflow.com/questions/9535227/getting-uname-information-from-a-compressed-kernel-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!