DT_INIT, Initialization Function for a kernel module

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ShukantPal
Posts: 23
Joined: Tue Dec 12, 2017 6:51 am
Libera.chat IRC: XtremeCoder

DT_INIT, Initialization Function for a kernel module

Post by ShukantPal »

I am creating a modular kernel, and for that I have a ModuleLoader. I have read that for freestanding compilation the build system (ld) does not creating any DT_INIT dynamic entry in the table (dynamic section). Before creating threads for each module's KModuleMain function, I need a mechanism to call their internal initialization function especially to call the global object constructors. Does anyone know how to set a DT_INIT function in the linker-script for ld & how to call all global object constructors in the shared library (kernel modules are implemented as dynamic shared libraries in the CircuitKernel)?

Kernel-link: https://github.com/SukantPal/CircuitKernel
ShukantPal
Posts: 23
Joined: Tue Dec 12, 2017 6:51 am
Libera.chat IRC: XtremeCoder

Re: DT_INIT, Initialization Function for a kernel module

Post by ShukantPal »

Just found out the answer on my own while developing the C++ runtime features for my kernel :D . One linking the infamous crti.o and crtn.o object files, the DT_INIT and DT_FINI tags are automatically emitted by the compiler/linker toolchain. I don't think there is any other way to do so, right?
Post Reply