If the Linux kernel by itself is an ELF file, where can I find its ELF file?
2 Answers
On many systems you can find a compressed kernel in /boot, typically named vmlinuz-$(uname -r). The ELF executable contained therein can be extracted using the extract-vmlinux script, available in the kernel source code:
extract-vmlinux /boot/vmlinuz-$(uname -r) > vmlinux The result is an ELF file:
$ file vmlinux vmlinux: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=b28d236fad2fb7d0eb9bbe6eac766fb04406da3f, stripped (on x86-64).
If you’re building the kernel,
make vmlinux will produce the ELF executable.
-
make vmlinuxdoesn't work. Whatmakefileare you using?user14189198– user141891982020-09-22 10:45:55 +00:00Commented Sep 22, 2020 at 10:45 - The kernel’s Makefile.Stephen Kitt– Stephen Kitt2020-09-22 11:04:05 +00:00Commented Sep 22, 2020 at 11:04
On a desktop/server you will usually find the kernel in /boot.
Look for a file called vmlinuz-* (depends on your distribution).
How the kernel is loaded: https://www.kernel.org/doc/html/latest/admin-guide/initrd.html