Subject: Re: Loading LKMs at boot yields unresolved symbols, but from commandline it's OK
To: Jeff Rizzo <riz@boogers.sf.ca.us>
From: Quentin Garnier <cube@cubidou.net>
List: netbsd-users
Date: 03/04/2005 21:12:56
--5/6IVfYouxg+lu1D
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:
>=20
> >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
> >
>=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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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);

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"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.

--5/6IVfYouxg+lu1D
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQijBSNgoQloHrPnoAQIK1Qf9FGnf+KUe09I5ljfJ6vZ0YNOGHS970Oan
glTTmPhR2fZGlcNS0shnguAQnVQlKuuQtouYqB9kBaXX2JO8vi7eAxMDmi//NE24
HvEDOxJRtNLn6v9H6DWE06IHQjdayCb5+LZbXQGbFNPa+VM3jLQEreiB49x98qJ8
b2iYzxsJssnnb70/vBYDeF/hlnDPR7NNkw7Hywbj6td45uUn2AHKlM51hhTTAlbS
UwoccM8Nm+Dnw2Bk4H2atpnxEI086382+wJMHiGTYV/U6cxZQ5AVfq0JK0a+4I9c
Bxa+nrJ6uGlgpWeRVLARNqvjlChGxEKEF6N6TK3JBnjzmYIqtFy1/Q==
=8NzJ
-----END PGP SIGNATURE-----

--5/6IVfYouxg+lu1D--