Subject: LKMs.
To: None <>
From: Matt Thomas <>
List: port-powerpc
Date: 02/19/2003 01:26:49
One of the problems with some of the PPC ports is due to linker
limitations, you can't do LKMs with doing "hacks" to the kernel.

This has always annoyed me since I felt the problem the problem
was in the toolchain.

Using readelf(1) and ld(1)'s --wrap, I've cobbled a small shell
script which given a LKM file as input will emit a new file
which can be used as LKM.

It works by finding all the unresolved branches and creates
trampolines for them.  Then by using --wrap symbol ld will changes
references to symbol to __wrap_symbol and then any references to
__real_symbol to symbol.  So for each symbol it emits a small

         lis     0,__real_free@h
         ori     0,0,__real_free@l
         mtctr   0

It emits a single .S with all the trampolines, assembles it,
and merges it into the LKM object.  Now you have a LKM object
which can be put anywhere.

Now to figure out how to get to do for PPC automatically.

Matt Thomas               Internet:
3am Software Foundry      WWW URL:
Cupertino, CA             Disclaimer: I avow all knowledge of this message