1
votes

I have been very interested in the Linux Kernel and operating systems in general. The thing i was wondering was, what is the file type or extension that a kernel has? It obviously doesn't have a .exe or .out extension because they are used for applications installed on operating systems.

Is a kernel just a Binary file?

Bonus question: I know that the Linux Kernel source code is divided over many .c files, but i was wondering if, when compiling, all these files are compiled into a single binary file or are the linked externally?

(I hope my queston(s) are not to vague)

2
To answer your bonus question, compile a kernel and you'll see (the process is verbose enough than you can tell what's going on, but not so verbose as to flood you with gcc output). As for the rest of your post, the kernel is a binary file, and usually has no extension.Frédéric Hamidi
Try the file command on the kernel executable. (Sorry, off the top of my head, I don't know the full path, and I'm not on a Linux machine at the moment) file knows more than a file name extension, with details such as architecture, etc.donjuedo

2 Answers

5
votes

The Linux Kernel (or any other OS Kernel) is just a binary image containing machine code for the target architecture. It is kinda like a statically linked executable, because there's no operating system to link any dependecy before it's running,so that once loaded in the main memory, it is able to execute without any other helper. This doesn't mean that it cannot load any other module dynamically. In Linux, this behavior is easily seen when you load a module from userspace (it's different process from loading a .so file tough).

That image may be compressed before being stored in the filesystem, and that's why you may get something like this output from "file":

file /boot/vmlinuz-2.6.39-400.215.7.el6uek.x86_64

/boot/vmlinuz-2.6.39-400.215.7.el6uek.x86_64: Linux kernel x86 boot executable bzImage, version 2.6.39-400.215.7.el6uek.x86_64 , RO-rootFS, swap_dev 0x3, Normal VGA

0
votes

Kernel may or may not contain single file. When you burn an OS image on some USB or drive, it changes the file system of that very USB or drive and than it becomes easy for the OS to search for .bin files so linking is done this. And yeah, a kernel can be an exe file. I just created a small kernel that has just one exe file.

It's possible to make an exe file independent of OS. check here to see a kernel of only one exe file. Also check this see how linking of multiple binary files is possible.