TheLoneJoker
TheLoneJoker

Reputation: 1629

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

Upvotes: 5

Views: 5843

Answers (3)

Avadhana Technologies
Avadhana Technologies

Reputation: 692

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

Upvotes: 2

New to Rails
New to Rails

Reputation: 2942

Try the following to find out what they are.
file vmlinux
file vmlinux.o

Check your make file to find out how vmlinux is prepared. This will shed some light.
It is not necessary that if vmlinux.o is used to prepare vmlinux, the size of vmlinux must be greater than vmlinux.o

Upvotes: 0

challinan
challinan

Reputation: 2764

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!

Upvotes: 5

Related Questions