Hi Michael,
Michael Roitzsch schrieb:
When creating the final binary, the linker has the habit of throwing code out it considers unused. For library constructors, this can go wrong, because the calls to them are generated only at runtime and are thus not visible to the linker, which then wrongly concludes to drop them.
The fix (actually it's more of a workaround) is to rename the static library in the Makefile TARGET from libdriver.a to libdriver.o.a. This causes the build system to combine the individual objects into one large object instead of a regular static library archive. You can later link to that lib with -ldriver.o as expected.
The effect is that the linker cannot throw code out of such a lib, because to it, this is essentially one large object file and the GNU linker only drops code with object granularity. (So this uses one peculiarity of the GNU linker to fix another one.)
Ack. Thanks for that hint. Your proposal works like a charm. Here is another solution: I wrote a small "hello-world" Linux kernel module with just two functions: init_module() and exit_module(). I thought that would be enough for demonstration. My fault. The linker needs at least one _real_ reference. So adding a further print_hello() function to the module and a call to that function from within my L4 server fixed the whole problem. Now, I see DDE calling my init function.
Thanks very much.
Andre