Issue
I have compiled the latest Linux kernel in default configuration with debug enabled using make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
commands for the arm64 target. I got the file vmlinux
in the root folder and Image
file in arch/arm64/boot
.
On QEMU I am able to boot the 'Image' file but not the 'vmlinux' file using the following command.
//Boots
qemu-system-aarch64 -semihosting -m 1024M -nographic -machine virt,gic-version=3,virtualization=on -cpu max -kernel mylinux/arch/arm64/boot/Image
//Not booting
qemu-system-aarch64 -semihosting -m 1024M -nographic -machine virt,gic-version=3,virtualization=on -cpu max -kernel linux/vmlinux
The result of file command is also given below.
$ file vmlinux
vmlinux: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=65799dedbc4bed593ecec1fe49d7b267, with debug_info, not stripped
$ file arch/arm64/boot/Image
arch/arm64/boot/Image: MS-DOS executable PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows
May I know the exact difference between these two files and why one file is booting.
Solution
"vmlinux" is a file which is created in the process of building kernel file from the sources. It is saved in ELF format. Then it can be used for debugging purposes using some debugger (i.e. GDB). It is not used for booting the systems.
Basing on this "vmlinux" ELF file there are created other files - like "Image". "Image" is a file which consists of some parts of vmlinux plus some boot code and this boot code is then used by bootloaders to start the kernel on the system.
Answered By - user2699113 Answer Checked By - Cary Denson (WPSolving Admin)