x86 kernel build chain - how bzImage gets created
Hi All,
Hopefully this will help demystify the build process
Notation:
<primary input file> (<file size in bytes>)
|
+ <additional input file>
|
* <command>
|
\-> <output file> (<file size in bytes>)
The file sizes are arbitrary and are based on the current configuration options I have set for a small kernel. They are simply there to illustrate the relative differences in file sizes.
Note that vmlinux.o is not used to generate bzImage but I've included it for completeness
+ arch/x86/kernel/head_32.o
+ arch/x86/kernel/head32.o
+ arch/x86/kernel/head.o
+ arch/x86/kernel/init_task.o
+ init/built-in.o
+ usr/built-in.o
+ arch/x86/built-in.o
+ kernel/built-in.o
+ mm/built-in.o
+ fs/built-in.o
+ ipc/built-in.o
+ security/built-in.o
+ crypto/built-in.o
+ block/built-in.o
+ lib/lib.a
+ arch/x86/lib/lib.a
+ lib/built-in.o
+ arch/x86/lib/built-in.o
+ drivers/built-in.o
+ sound/built-in.o
+ firmware/built-in.o
+ arch/x86/pci/built-in.o
+ net/built-in.o
|
* ld -m elf_i386 -r -o vmlinux.o
|
\->vmlinux.o (2,889,050)
+ arch/x86/kernel/head_32.o
+ arch/x86/kernel/head32.o
+ arch/x86/kernel/head.o
+ arch/x86/kernel/init_task.o
+ init/built-in.o
+ usr/built-in.o
+ arch/x86/built-in.o
+ kernel/built-in.o
+ mm/built-in.o
+ fs/built-in.o
+ ipc/built-in.o
+ security/built-in.o
+ crypto/built-in.o
+ block/built-in.o
+ lib/lib.a
+ arch/x86/lib/lib.a
+ lib/built-in.o
+ arch/x86/lib/built-in.o
+ drivers/built-in.o
+ sound/built-in.o
+ firmware/built-in.o
+ arch/x86/pci/built-in.o
+ net/built-in.o
+ .tmp_kallsyms2.o
|
* ld -m elf_i386 --build-id -T arch/x86/kernel/vmlinux.lds |
\->vmlinux (2,629,659)
|
* objcopy -R .comment -S
|
\->arch/x86/boot/compressed/vmlinux.bin (2,094,132)
|
* gzip
|
\-> arch/x86/boot/compressed/vmlinux.bin.gz (1,074,711)
|
* .incbin
|
\-> piggy.S
|
* gcc
|
\-> piggy.o (1,075,419)
|
+ arch/x86/boot/compressed/head_32.o
+ arch/x86/boot/compressed/misc.o
+ arch/x86/boot/compressed/string.o
+ arch/x86/boot/compressed/cmdline.o
+ arch/x86/boot/compressed/early_serial_console.o
|
* ld -m elf_i386 -T arch/x86/boot/compressed/vmlinux.lds
|
\->arch/x86/boot/compressed/vmlinux (1,099,538)
|
* objcopy -O binary -R .note -R .comment -S
|
\-> arch/x86/boot/vmlinux.bin (1,092,060)
|
| + arch/x86/boot/a20.o
| + arch/x86/boot/bioscall.o
| + arch/x86/boot/cmdline.o
| + arch/x86/boot/copy.o
| + arch/x86/boot/cpu.o
| + arch/x86/boot/cpucheck.o
| + arch/x86/boot/early_serial_console.o
| + arch/x86/boot/edd.o
| + arch/x86/boot/header.o
| + arch/x86/boot/main.o
| + arch/x86/boot/mca.o
| + arch/x86/boot/memory.o
| + arch/x86/boot/pm.o
| + arch/x86/boot/pmjump.o
| + arch/x86/boot/printf.o
| + arch/x86/boot/regs.o
| + arch/x86/boot/string.o
| + arch/x86/boot/tty.o
| + arch/x86/boot/video.o
| + arch/x86/boot/video-mode.o
| + arch/x86/boot/version.o
| + arch/x86/boot/video-vga.o
| + arch/x86/boot/video-vesa.o
| + arch/x86/boot/video-bios.o
| |
| * ld -m elf_i386 -T arch/x86/boot/setup.ld
| |
| \->arch/x86/boot/setup.elf (186,171)
| |
| * objcopy -O binary arch/x86/boot/setup.elf
| |
+ \-> arch/x86/boot/setup.bin (12,604)
|
* arch/x86/boot/tools/build
|
\-> arch/x86/boot/bzImage (1,104,864)Quoted 13 lines · Graeme Russ
Hi All,
Hopefully this will help demystify the build process
Notation:
<primary input file> (<file size in bytes>)
?|
?+ <additional input file>
?|
?* <command>
?|
?\-> <output file> (<file size in bytes>)
Quoted 3 lines
The file sizes are arbitrary and are based on the current configuration options I have set for a small kernel. They are simply there to illustrate the relative differences in file sizes.
Great! Thanks for sharing this.
Quoted 2 lines
Note that vmlinux.o is not used to generate bzImage but I've included it for completeness
[...]
Quoted 5 lines
+
net/built-in.o
|
* ld -melf_i386-r -o vmlinux.o
|
\->vmlinux.o (2,889,050)
What is the purpose of vmlinux.o then?
thanks,
Daniel.
Hi Daniel
Quoted 14 lines · Daniel Baluta
Quoted 13 lines · Graeme Russ
Hi All,
Hopefully this will help demystify the build process
Notation:
<primary input file> (<file size in bytes>)
|
+ <additional input file>
|
* <command>
|
\-> <output file> (<file size in bytes>)
Quoted 5 lines
Quoted 3 lines
The file sizes are arbitrary and are based on the current configuration options I have set for a small kernel. They are simply there to illustrate the relative differences in file sizes.
Great! Thanks for sharing this.
Your welcome :)
Quoted 4 lines
Quoted 3 lines
Note that vmlinux.o is not used to generate bzImage but I've included it for completeness
Quoted 8 lines
[...]
Quoted 5 lines
+
net/built-in.o
|
* ld -melf_i386-r -o vmlinux.o
|
\->vmlinux.o (2,889,050)What is the purpose of vmlinux.o then?
I don't know - Anyone?
Regards,
Graeme
Quoted 3 lines · Graeme Russ
Hi All,
Hopefully this will help demystify the build process
Hi!
Wow great man! I deeply suggest to write that into kernelnewbies wiki too....
Once again, great job!
Signature · 7 lines
regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Hi Mulyadi Santosa
Quoted 9 lines · Mulyadi Santosa
Quoted 3 lines · Graeme Russ
Hi All,
Hopefully this will help demystify the build process
Hi!
Wow great man! I deeply suggest to write that into kernelnewbies wiki too....
I've had another followup suggestion to add this to the wiki. I don't have permissions to add or edit wiki pages, so if someone feels like adding me as a wiki editor then I can do it soon enough, otherwise, I'm happy for any existing editor to create a new page. /Documents/bzImageBuildProcess is where I would think to put it.
Also, I'm in the process of disecting the x86 boot_params and associated structures, what members are used where etc including the 'header.bin' 16-bit real-mode initialisation code and the kernel decompression and start of execution which, I think, would be worth adding to the wiki when done
I've created a wiki account (GraemeRuss) so if anyone wants me to add a new page, add me to the editors list, send me and email, and I will get to it
Quoted 2 lines
Once again, great job!
Thanks,
Graeme