Dynamic linking. Import / Export of symbols.
Posted: Wed Jun 16, 2010 6:19 am
Hi,
I compile my loadable modules as objects that export a set of functions. That works well.
Now i need to import functions aswell for those same modules. My code works for both ELF and PE, but the PE loader is more functional at the moment. My goal is to support both ELF and PE dynamlic loading, relocation and calling between both formats.
Now my issue is when i compile the modules and include kernel functions from the kernel headers. I have configured the KERNEL_API macro and the MODULE_API macro to be either __declspec(dllimport) / dllexport based on what is compiling. That seems to work, but the problem is my module gets "unresolvable symbol" during linking. The binary have exports and imports + relocations in its file. The exports look normal, but my imports is prefixed with __IMP__ on the symbol name.
Any idea what is wrong? I guess the __IMP__ should be a code-stub/trampoline in the file that can be patched to jump to the function in mention in the kernel for this case.. Do i need to create some sort of lib from the kernel (that makes this stubs) and link it into my module statically?
I use MS vc++ 2010 for compiling now. Makefiles are working for gcc and intel c++ answell, but i dont think this is a compiler issue,, more like linker usage / config..
Anyone got any ideas how i fix this?
-
Thomas
I compile my loadable modules as objects that export a set of functions. That works well.
Now i need to import functions aswell for those same modules. My code works for both ELF and PE, but the PE loader is more functional at the moment. My goal is to support both ELF and PE dynamlic loading, relocation and calling between both formats.
Now my issue is when i compile the modules and include kernel functions from the kernel headers. I have configured the KERNEL_API macro and the MODULE_API macro to be either __declspec(dllimport) / dllexport based on what is compiling. That seems to work, but the problem is my module gets "unresolvable symbol" during linking. The binary have exports and imports + relocations in its file. The exports look normal, but my imports is prefixed with __IMP__ on the symbol name.
Any idea what is wrong? I guess the __IMP__ should be a code-stub/trampoline in the file that can be patched to jump to the function in mention in the kernel for this case.. Do i need to create some sort of lib from the kernel (that makes this stubs) and link it into my module statically?
I use MS vc++ 2010 for compiling now. Makefiles are working for gcc and intel c++ answell, but i dont think this is a compiler issue,, more like linker usage / config..
Anyone got any ideas how i fix this?
-
Thomas