Linker script confuses physical and virtual addresses
Posted: Mon Dec 09, 2024 11:52 am
In my continuing of implementing paging for my kernel, I've decided to load .text at 0xc0000000, .rodata at 0xc0040000, .data at 0xc0080000 and .bss at 0xc00c0000. I have the following section in my linker script:
When I test the linker script, QEMU significantly lags my computer. When I pass the image through , I notice _text_end is 0xc020514b, which means QEMU was probably trying to allocate 3 GiB memory. How can this be? The values of _text_end_virt and _mbtext_end are 0xc000412e and 0x0020101d, so _text_end should be 0x20514b. Does LD somehow not respect operator precedence when calculating values?
Code: Select all
.multiboot.text : ALIGN(4K)
{
*(.multiboot.text)
_mbtext_end = .;
ASSERT(_mbtext_end < 0x202000, "Paging setup code exceeds page boundary!");
}
. = 0xC0000000;
_kernel_base = .;
.text ALIGN(4K) : AT (_mbtext_end)
{
*(.text)
*(.text.*)
_text_end_virt = .;
_text_end = _text_end_virt - 0xC0000000 + _mbtext_end;
}
[...]
Code: Select all
nm