Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between vmlinux and vmlinux.o

When I build the Linux kernel, two images are generated vmlinux and vmlinux.o. They both seem to differ in size as well (113KB and 198KB respectively...). Could someone provide insight into the differences ?

Thanks,

Vj

like image 876
TheLoneJoker Avatar asked Jul 12 '13 18:07

TheLoneJoker


People also ask

What is difference between vmlinux and vmlinuz?

vmlinux: A non-compressed and non-bootable Linux kernel file format, just an intermediate step to producing vmlinuz . vmlinuz: A compressed and bootable Linux kernel file.

What is vmlinux used for?

The vmlinux file might be required for kernel debugging, symbol table generation or other operations, but must be made bootable before being used as an operating system kernel by adding a multiboot header, bootsector and setup routines.

What is zImage and bzImage?

The file called zImage is the compressed kernel image that lives in arch/i386/boot after you issued make zImage or make boot -- the latter invocation is the one I prefer, as it works unchanged on other platforms. If you built a big zImage, instead, the file is called bzImage, and lives in the same directory.

What is the difference between image zImage and uImage image type targets for Linux kernel?

What is the difference between them? Image: the generic Linux kernel binary image file. zImage: a compressed version of the Linux kernel image that is self-extracting. uImage: an image file that has a U-Boot wrapper (installed by the mkimage utility) that includes the OS type and loader information.


2 Answers

The images produce during a Linux build vary by architecture and target. There are many intermediate build targets besides those two mentioned in the question. Most are uninteresting except possibly for academic purposes. Unfortunately, there is more than one target named vmlinux. vmlinux.o is not very interesting. At the top level Linux tree, you will find an ELF file called vmlinux. Executing

$ file vmlinux

should confirm that this is the ELF file. I don't know of any systems that boot this file directly. The only time this file is interesting is for debugging, because it contains debug symbols that a debugger can read. The actual boot target will be found in a subdirectory depending on architecture. For x86, (thought that's not my expertise) I think you'll find a target called bzImage. For ARM architectures, some systems boot zImage, others boot uImage (which is a Linux kernel image packaged in a header that the U-Boot bootloader recognizes. Even if you remove the U-Boot header, the image is a composite image. That is, it's not an ELF file, and it's not a pure .o, etc. It is a concatenation of several binary blobs, which can include kernel configuration information, the kernel itself, almost always compressed, and often a piece of runnable code (ie. not compressed) that I call a "bootstrap" loader, which often contains machine and board-specific initialization routines. I'm less familiar with x86, but even on that architecture, the kernel boot image (the one that you boot) is a composite image containing several components, ie. not a pure .o or ELF file.

One good way to see what is happening is to compile your kernel with verbose mode, and then watch the final steps to see how the images are manipulated. Add V=1 to the 'make' command line to turn on verbose mode.

Happy hacking!

like image 185
challinan Avatar answered Sep 30 '22 16:09

challinan


When the Linux kernel is build, two images are generated vmlinux and vmlinux.o.

vmlinux.o : Is Relocatable object file

vmlinux : Is Executable file

Linker takes relocatable object files and command line arguments in order to generate an executable object file. To produce an executable file the Linker has to perform the symbol resolution, and Relocation.

Perform ‘file’ and ‘readelf’ command on vmlinux.o and vmlinux for more info.

root@beaglebone:/home# file vmlinux

vmlinux: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, BuildID[sha1]=0xdfd102a3c2b79fcc2f1949323dc54b9371c75608, not stripped

root@beaglebone:/home#

root@beaglebone:/home# file vmlinux.o

vmlinux.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

like image 43
Kushal Avatar answered Sep 30 '22 16:09

Kushal