Hello, this is my first post on the rust forum. I normally don't make posts on forums but since there is (almost) nothing of examples for what i want to do and have no idea how to start.
So the goal is to load a dylib at runtime in my custom kernel. The dylib is meant as a module for my kernel.
That means that the finshed product can load an dylib execute a predefined function and access kernel functions and also other modules.
The problem is when i want to compile my module to the target (x86_64 baremetal) it says it doesn't support dylib as crate target.
If i am correct this is because i never defined how a dynamic library should work in my own kernel?
If so how do i fix this? Where do i start?
Just to be sure, am i in the correct category?
EDIT:
The crates with their dependencies:
kernel (bin)
kernel-core
example-module-1 (dylib)
kernel-core
example-module-2 (dylib)
kernel-core
example-module-1
kernel-core (lib)
The ideal solution would be that kernel-core is staticly linked in the kernel and modules acces it from there.
The example you gave makes use of the crate type staticlib, i can't use this since it static links all the dependencies such as other modules. (core and alloc are already linked in the kernel itself so i would also like to avoid adding those to each module)
Then the kernel binary won't export any symbols other than the start function. This means that any symbols in kernel-core won't be available for the kernel modules.
kernel-core is linked into the kernel, so no. That would only be possible if kernel-core were to be a dylib, but then kernel would need to be linked itself, requiring you to write your own bootloader or a stub that links the rest of the kernel.
Full re-edit, i looked somewhat more things up about dynamic link etc. I can make my own dynamic linker in my kernel that loads ELF files, i just need my rust compiled as an dylib so that i can feed it into my own dynamic linker.