Higher Half Kernel and how linker work
Posted: Wed Feb 02, 2022 7:14 am
Hello.
I'm following the tutorial on creating a higher half kernel, but I can't figure out why, when accessing each symbol in the code, 0xC0000000 is subtracted
In the first line in the _start function, when accessing the boot page table, 0xC0000000 is subtracted from it
or there
Why do this? After all, in the linker using AT(addr) we indicate the real location of the section in the lower half, then why subtract?
I assume that the changed value of the "." operator affects the symbol table and they really point to the higher half, but I did not find confirmation of this in the linker documentation.
I'm following the tutorial on creating a higher half kernel, but I can't figure out why, when accessing each symbol in the code, 0xC0000000 is subtracted
In the first line in the _start function, when accessing the boot page table, 0xC0000000 is subtracted from it
Code: Select all
# Physical address of boot_page_table1.
movl $(boot_page_table1 - 0xC0000000), %edi
Code: Select all
# Map the page table to both virtual addresses 0x00000000 and 0xC0000000.
movl $(boot_page_table1 - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 0
movl $(boot_page_table1 - 0xC0000000 + 0x003), boot_page_directory - 0xC0000000 + 768 * 4
I assume that the changed
Code: Select all
. += 0xC0000000;