icexin / eggos

A Go unikernel running on x86 bare metal
http://eggos.icexin.com
MIT License
2.21k stars 112 forks source link

trying to understand linking process #22

Closed sauravdeshpande closed 3 years ago

sauravdeshpande commented 3 years ago

Osdev.wiki use a linker script, but i could not find one in the repo. I want to understand where have you included the process of the linker, can you please guide me through this part.

Thank you

icexin commented 3 years ago

Linker is used in two places, one is to build the multiboot header, see https://github.com/icexin/eggos/blob/f2adf1056fecb7c766cafa68de48a711dd2ba33c/Makefile#L62 The other place is to build kernel.elf, see https://github.com/icexin/eggos/blob/f2adf1056fecb7c766cafa68de48a711dd2ba33c/Makefile#L57

The reason why linker script is not used is that the virtual address and load address of the kernel are the same, and no complicated logic is needed to change the link process. Another reason is that the go language has its own linker, and it will be more complicated to use the linker script.

Hope this helps.

sauravdeshpande commented 3 years ago

Thank you