DDE legacy kernel module as library

Michael Roitzsch mroi at os.inf.tu-dresden.de
Wed Feb 18 11:06:33 CET 2009


Hi Andre,

> I want to keep the legacy kernel module code inside a separate  
> library which is than linked to my DDE application. The module's  
> "init" method is included in the library but not inside the final  
> binary. That's why it is not called by l4dde26_do_initcalls().

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.)

Michael





More information about the l4-hackers mailing list