help loading driver modules with ELF?
Posted: Mon Jan 13, 2020 7:11 pm
Hi all,
In my 32 bit x86 OS I can load executables via ELF into user space at a fixed virtual address (usually 0x80000000). But now I want to start putting drivers in "kernel modules" and loading them at run-time and I want to use ELF for this too. The problem I'm having is that obviously kernel modules will not have their own virtual memory space so I can't just their load segments that at whatever address is specified in the elf program header.
So clearly they have to be relocated and this is where I am getting confused, because there seems to be more than one kind of "relocation" when it comes to ELF, and I'm not sure which applies to kernel modules. Should I be building my modules as relocatable files e.g. ld -r, or as dynamic libraries with position independent code? Does relocation really require that I use the section header (which are unused for my executable loader), or is the information in the program header table?
here is my current likely flawed elf code for user executables : https://github.com/pgrAm/JSD-OS/blob/ma ... rnel/elf.c. How would I go about adding support for relocation to this?
I'm interested in how you chose to implement kernel modules if you have them? And if they should dynamic libraries can someone refer me to some resources on how to load/relocate these?
In my 32 bit x86 OS I can load executables via ELF into user space at a fixed virtual address (usually 0x80000000). But now I want to start putting drivers in "kernel modules" and loading them at run-time and I want to use ELF for this too. The problem I'm having is that obviously kernel modules will not have their own virtual memory space so I can't just their load segments that at whatever address is specified in the elf program header.
So clearly they have to be relocated and this is where I am getting confused, because there seems to be more than one kind of "relocation" when it comes to ELF, and I'm not sure which applies to kernel modules. Should I be building my modules as relocatable files e.g. ld -r, or as dynamic libraries with position independent code? Does relocation really require that I use the section header (which are unused for my executable loader), or is the information in the program header table?
here is my current likely flawed elf code for user executables : https://github.com/pgrAm/JSD-OS/blob/ma ... rnel/elf.c. How would I go about adding support for relocation to this?
I'm interested in how you chose to implement kernel modules if you have them? And if they should dynamic libraries can someone refer me to some resources on how to load/relocate these?