Making the kernel a dynamically loaded executable (pie)
Posted: Tue Sep 16, 2025 10:54 am
Dear Forum,
I am working on making my kernel a dynamicall loaded executable, to use limines KASLR, for some days now and still can't get it to work properly.
This is my repository: https://github.com/sebihepp/HeppOS
I expect the problem to be in the linker script, specifically the PHDRs and sections. Depending on how I arrange the linker script, I can get qemu to work and bochs to triple fault in the middle of the kernel, both to triple fault directly when my kernel gets executed, or limine to print errors like "PT_DYNAMIC is of size 0, etc." on both emulators.
I totally lack the understanding of my linker and linker script in respect to PIEs (Position independent executables). I searched the last days for information what limine expects from such an executable, info on which sections are needed for PIEs and how to get the PHDRs right, but found absolutely nothing.
Could you please assist me? Maybe just a pointer into the right direction? Which documentation to read, etc.
Best regards
Sebi
I am working on making my kernel a dynamicall loaded executable, to use limines KASLR, for some days now and still can't get it to work properly.
This is my repository: https://github.com/sebihepp/HeppOS
I expect the problem to be in the linker script, specifically the PHDRs and sections. Depending on how I arrange the linker script, I can get qemu to work and bochs to triple fault in the middle of the kernel, both to triple fault directly when my kernel gets executed, or limine to print errors like "PT_DYNAMIC is of size 0, etc." on both emulators.
I totally lack the understanding of my linker and linker script in respect to PIEs (Position independent executables). I searched the last days for information what limine expects from such an executable, info on which sections are needed for PIEs and how to get the PHDRs right, but found absolutely nothing.
Could you please assist me? Maybe just a pointer into the right direction? Which documentation to read, etc.
Best regards
Sebi