How vmlinux is recognized?

Manohar Vanga manohar.vanga at gmail.com
Wed May 11 16:33:52 EDT 2011


Hi Vikram,

How the vmlinux (an ELF executable) is recognized by the processor?
>

ELF is just a file format. That is, the machine instructions and data are
stored in a specific format. The _processor_ simply recognizes machine
instructions and this needs to be taken from the ELF file and loaded into
memory (the instruction pointer is then pointed to the place the
instructions were loaded).

The format is simply a set of rules defined in the specification (a pretty
nice introduction is available at www.skyfree.org/linux/references/*ELF*
_Format.pdf <http://www.skyfree.org/linux/references/ELF_Format.pdf>). For
example, when you ask a Linux kernel to execute an ELF file, it has code to
know how to decode the information and place it into memory (see
fs/binfmt_elf.c).

As for the vmlinux file specifically, the Wikipedia page on vmlinux (
http://en.wikipedia.org/wiki/Vmlinux) seems like a good start. As shown
above with Linux, GRUB needs to have a way to decode whatever format is
passed to it (bzImage).

The kernel however places the unzipping code into the bzImage itself so that
it is loaded into memory by the bootloader and is then run. This code then
unzips the kernel. This way, GRUB doesn't need to know how to decode ELF
files and the job is left to the kernel code. You can see
arch/x86/boot/Makefile and look for the bzImage target to see what files
constitute the bzImage. I may be wrong about this with regard to newer
kernels so I hope others correct me in this case. Another great explanation
is by Alessandro Rubini at:

http://www.ibiblio.org/oswg/oswg-nightly/oswg/en_US.ISO_8859-1/articles/alessandro-rubini/boot/boot/zimage.html

Hope this helped! :-)

-- 
/manohar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110511/b7913e0b/attachment.html 


More information about the Kernelnewbies mailing list