Subject: Re: Loading LKMs at boot yields unresolved symbols, but from commandline it's OK
To: Jeff Rizzo <>
From: Quentin Garnier <>
List: netbsd-users
Date: 03/04/2005 21:12:56
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Mar 04, 2005 at 10:47:36AM -0800, Jeff Rizzo wrote:
> Quentin Garnier wrote:
> >On Fri, Mar 04, 2005 at 09:32:02AM -0800, Jeff Rizzo wrote:
> >[...]
> > =20
> >
> >>The problem:  if I load the LKMs from the commandline, it's fine.=20
> >>However, when I configure things in lkm.conf for boot-time load, I get
> >>undefined reference errors.  This is *with* the -s flag.
> >>   =20
> >>
> >
> >Hmm.  At first I thought it was kern/29133, but I'm not that sure.
> >
> >I'm wondering a bit about the part in /etc/rc.lkm where it adds
> >-A unconditionally (well, as long as the kernel is readable).  Could
> >you try with that part commented out?  (It begins with booted_kernel.)
> >
> > =20
> >
> Sure enough, with that part commented out, it loads just fine.  What do
> you think the best general-purpose solution is?

Right now, if -A is passed, ksyms is not used, so indeed the second load
can't resolve the symbols of the first one.

You said it works for someone else; now I wonder why.  My guess is that
his kernel file is not readable, or machdep.booted_kernel doesn't return
a correct value.

I think -s and -A should conflict:  if you inject symbols into the
running kernel, you want to use the kernel to resolve the symbols, so if
ksyms are accessible, they should be preferred.

What do people think of this?  It has ksyms preferred if -s is passed.
Jeff, can you try it?  Just in case :-)

Index: modload.c
RCS file: /cvsroot/src/sbin/modload/modload.c,v
retrieving revision 1.49
diff -u -r1.49 modload.c
--- modload.c	27 Oct 2004 19:36:31 -0000	1.49
+++ modload.c	4 Mar 2005 20:11:31 -0000
@@ -357,7 +357,7 @@
 	 * Check if /dev/ksyms can be used.
-	if (kname =3D=3D NULL) {
+	if (symtab || kname =3D=3D NULL) {
 		int fd =3D open(_PATH_KSYMS, O_RDONLY);
 		if (fd < 0) {
 			warn("%s", _PATH_KSYMS);

Quentin Garnier - -
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.6 (NetBSD)