Subject: In-kernel symbol table + /dev/ksyms
To: None <tech-kern@netbsd.org>
From: None <ragge@ludd.luth.se>
List: tech-kern
Date: 04/07/2003 13:31:14
While searching in some old code I had I found a dusty implementation
of an in-kernel symbol table manager + a /dev/ksyms implementation.
I think this would be a good step towards a better handling of loadable
kernel modules.

This adds two files to the kernel:
sys/kern/kern_ksyms.c
sys/sys/ksyms.h

This will mostly affect DDB, in that DDB's own symtab handling is removed
and replaced with this. Also, the a.out support in DDB goes away fully,
but I do not consider that as a problem.

The /dev/ksyms interface presents an ELF file with only symtab and
strtab segments in it.  It works well to do things like "gdb /dev/ksyms"
+ "target kcore /dev/mem" to play with a live system.

This code is included in the kernel by three config options:

pseudo-device ksyms
options DDB
options LKM

There are trivial changes needed to modload + the kvm routines to
make use of /dev/ksyms.

Comments on this?

If nothing revolutionaly comes up, I will fix so that the code works
in -current also (it was written for pre-1.4) and do some testings
on 64-bit archs.  I plan to have a patch for the kernel sources ready
at the end of this week for review.

Progress:

The next step would be to fix the basic in-kernel linker. I have an
ELF linker written (for the PDP10 port) and I don't think it would 
be difficult to make it run in-kernel.

The last step would be to make the linker interact correctly with the
autoconf system.  This has some hairy problems to solve, but that is a 
future task.

-- Ragge