operating system - How should a UEFI bootloader load the kernel? - Stack Overflow

admin2025-04-15  3

Sa miaj amikoj! I am writing an UEFI bootloader in Zig (+ kernel).

I am sorry if i come across as a buffoon but i've barely programmed before

The bootloader part is easy. but now im stuck on how to compile the kernel and load it:

  • The Zig language does have a raw output format. I was joyed. but its been in the to-do list since who knows how long. So i need to keep using ELF for now

  • So maybe i'll just jump to e_entry but it is nowhere near offset of .text so I am kinda thrown off

  • I could extract .text.data.rodata. and just concat them together to make a jmp'able format. but I am sure it would jump to .rodata somehow. (maybe i need to parse x86 assembly and update the addresses?).

  • The most plausible idea for me right now is to keep the distance between the three sections the same and fill the space with 0xff

I have no idea how i should do it. All of the ideas in my head are straight buns. In fact i do not even know how to load an ELF binary. What should i do?

I tried making some ideas. All of them stinks. I expect none of them to work. And the result is i never actually compiled it so now i am writing this stackoverflow question

转载请注明原文地址:http://anycun.com/QandA/1744724532a86747.html