How does linux bootloaders load vmlinux file to memory when elf file is specified using virtual address and MMU is not set before kernel loading?

2

I'm confused. When I see /boot/grub/grub.cfg on my x86_64 ubuntu machine, the grub uses vmlinuz-4.15-..-generic file as kernel image. vmlinuz will be a compressed file of vmlinux and vmlinux is elf file having many object codes and data in many sections. And the addresses in the elf file is 'virtual' address not physical. The virtual -> physical address translation is done through page table and MMU hardware which is set by the kernel.
This is the start of decoded code from vmlinux for aarch64.(I got this from aarch64-none-elf-objdump -D vmlinux)

ffff800010080000 <_text>:
ffff800010080000:       91005a4d        add     x13, x18, #0x16
ffff800010080004:       1447ffff        b       ffff800011280000 <stext>
ffff800010080008:       00080000        .inst   0x00080000 ; undefined
ffff80001008000c:       00000000        .inst   0x00000000 ; undefined
ffff800010080010:       01938000        .inst   0x01938000 ; undefined

the kernel text starts at virtual address 0xffff800010080000. Before kernel is executed, and so before page table and MMU setting is done, how does the bootloader place the kernel image's various sections to each virtual address? I guess I'm not aware of a very import thing here. Please someone help me. Or, does the bootloader set up mmu table?(On second thought, I guess this may be the only solution)

linux
linux-kernel
embedded-linux
bootloader
asked on Stack Overflow Jan 25, 2021 by Chan Kim • edited Jan 25, 2021 by Chan Kim

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0