Does kernel Image file contains the elf format information ?

Kumar amit mehta gmate.amit at gmail.com
Tue Nov 27 00:10:37 EST 2012


On Tue, Nov 27, 2012 at 12:44:45PM +0800, horse_rivers wrote:
> hi,
>    when we compile kernel,gcc will put elf format information into the target file ,then we use build-tools construct the kernel Image,
> 
>   during this procedure,will elf information be copyed into Image file ?
> 
Yes, it does but as you know that the kernel image will be in the compressed
format, therefore you'll have to decompress it first. I tried following with my
kernel image and then I was able to use the 'readelf' and 'objdump' on the
extracted elf:

amit at ubuntu:/tmp$ cp /boot/vmlinuz-3.7.0-rc3-next-20121029 /tmp/
amit at ubuntu:/tmp$ od -A d -t x1 vmlinuz-3.7.0-rc3-next-20121029 | grep '1f 8b 08
00'
0016992 f3 a5 fc 5e 8d 83 b4 91 4f 00 ff e0 1f 8b 08 00
                             
amit at ubuntu:/tmp$ dd if=vmlinuz bs=1 skip=17004 | zcat > vmlinux

How did i calculated 17004 ?
0016992 + offset of GZ signature(1f 8b 08 00), i.e.
0016992 + 12

amit at ubuntu:/tmp$ dd if=vmlinuz-3.7.0-rc3-next-20121029 bs=1 skip=17004 | 
zcat > vmlinux
5233764+0 records in
5233764+0 records out
5233764 bytes (5.2 MB) copied

amit at ubuntu:/tmp$ file vmlinux
vmlinux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically
linked, BuildID[sha1]=0xb874d61ffd40167270bdc1a95274976200223cc0, stripped

amit at ubuntu:/tmp$ objdump -f vmlinux

vmlinux:     file format elf32-i386
architecture: i386, flags 0x00000102:
EXEC_P, D_PAGED
start address 0x01000000

For more information check the link [1] below.

- Amit

[1] http://forums.codeguru.com/showthread.php?415186-convert-vmlinuz-to-vmlinux



More information about the Kernelnewbies mailing list