arch/i386/boot/zImage or arch/i386/boot/bzImage respectively. Here is how the image is built:- C and assembly source files are compiled into ELF relocatable object format (.o) and some of them are grouped logically into archives (.a) using ar(1).To know more about ELF go through http://subramanyaachar.blogspot.com/2011/05/understanding-elf-1.html
- Using ld(1), the above .o and .a are linked into
vmlinuxwhich is a statically linked, non-stripped ELF 32-bit LSB 80386 executable file. System.mapis produced by nm vmlinux, irrelevant or uninteresting symbols are grepped out.- Enter directory
arch/i386/boot. - Bootsector asm code
bootsect.Sis preprocessed either with or without -D__BIG_KERNEL__, depending on whether the target is bzImage or zImage, intobbootsect.sorbootsect.srespectively. bbootsect.sis assembled and then converted into 'raw binary' form calledbbootsect(orbootsect.sassembled and raw-converted intobootsectfor zImage).- Setup code
setup.S(setup.Sincludesvideo.S) is preprocessed intobsetup.sfor bzImage orsetup.sfor zImage. In the same way as the bootsector code, the difference is marked by -D__BIG_KERNEL__ present for bzImage. The result is then converted into 'raw binary' form calledbsetup. - Enter directory
arch/i386/boot/compressedand convert/usr/src/linux/vmlinuxto $tmppiggy (tmp filename) in raw binary format, removing.noteand.commentELF sections. - gzip -9 < $tmppiggy > $tmppiggy.gz
- Link $tmppiggy.gz into ELF relocatable (ld -r)
piggy.o. - Compile compression routines
head.Sandmisc.c(still inarch/i386/boot/compresseddirectory) into ELF objectshead.oandmisc.o. - Link together
head.o,misc.oandpiggy.ointobvmlinux(orvmlinuxfor zImage, don't mistake this for/usr/src/linux/vmlinux!). Note the difference between -Ttext 0x1000 used forvmlinuxand -Ttext 0x100000 forbvmlinux, i.e. for bzImage compression loader is high-loaded. - Convert
bvmlinuxto 'raw binary'bvmlinux.outremoving.noteand.commentELF sections. - Go back to
arch/i386/bootdirectory and, using the program tools/build, cat togetherbbootsect,bsetupandcompressed/bvmlinux.outintobzImage(delete extra 'b' above forzImage). This writes important variables likesetup_sectsandroot_devat the end of the bootsector.
We will see later where this limitation comes from.
The upper limit on the bzImage size produced at this step is about 2.5M for booting with LILO and 0xFFFF paragraphs (0xFFFF0 = 1048560 bytes) for booting raw image, e.g. from floppy disk or CD-ROM (El-Torito emulation mode).
Note that while tools/build does validate the size of boot sector, kernel image and lower bound of setup size, it does not check the *upper* bound of said setup size. Therefore it is easy to build a broken kernel by just adding some large ".space" at the end of
setup.S.To Be continued

No comments:
Post a Comment