Anyway, I've worked out a scheme by which I can link any arbitrary
driver *module* into an uncompressed kernel image (vmlinux, not
vmlinuz), by doing some link-time symbol fiddling. Essentially, I
first build a kernel with something like this in the init code:
extern int driver_stub(void);
static int (*driver_ptr)(void) = driver_stub;
{
if (driver_ptr != NULL) driver_ptr();
}
and I link vmlinux with "-defsym driver_stub=NULL". Now, this vmlinux
file has no undefined references, but I can later redefine driver_stub
to point to something else, by doing something like:
ld -o vmnew -defsym driver_stub=init_module vmlinux pcmcia.o
With some extra "-defsym" fiddling, I can take care of kernels with
module version checking, also. And I can use "strip" to get rid of
the init_module and cleanup_module symbols, so that I can repeat the
process to link multiple modules.
It seems like this could be a nice replacement for the current scheme
of having different object files for drivers compiled as loadable
modules, or compiled to be linked directly into the kernel. Also, it
makes most configuration options link-time instead of compile-time.
What do people think about this as a way of revamping how kernels are
configured for different driver sets? I plan to finish implementing
it for PCMCIA, at least, which should be a sort of proof-of-concept.
-- Dave Hinds
dhinds@hyper.stanford.edu