Subject: Re: Question about modules
To: Julio M. Merino Vidal <jmmv84@gmail.com>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 08/28/2005 17:26:01
--rpOPesfUXqAMaEty
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Aug 28, 2005 at 05:17:10PM +0200, Julio M. Merino Vidal wrote:
> On 8/28/05, Hans Petter Selasky <hselasky@c2i.net> wrote:
> > Hi,
> >=20
> > On FreeBSD they use the "__section__" attribute to do linking magic. Bu=
t on
> > NetBSD I am completely lost :-)
> >=20
> > 1) What is the logic behind linking modules?
> >=20
> > # pwd
> > /usr/src/sys/lkm/vfs/adosfs
> >=20
> > # ls
> > CVS             Makefile        lkminit_vfs.c
> >                                 ^^^ is there some
> >                        magic hidden in this filename?
> >=20
> > From where is the following function called:
> >=20
> > adosfs_lkmentry
>=20
> I guess this is because the structure defined by the MOD_VFS
> macro, whose name is _module.  See sys/lkm.h.
>=20
> After the structure is defined with a known name, the kernel
> can access it, get the vfs operations structure and call the
> vfs_init function from there.

Not really.  That part is done through DISPATCH().

> > Is this function also called when the module is
> > in the kernel ?
>=20
> If "this function" means vfs_init, then yes, it is called during
> system startup as a result of the VFS_ATTACH macro.

"This function" is adofs_lkmentry.

The entry point address is passed to the kernel by modload(8) as
part of the LKM API.

> > 2) Where is PSEUDO_SET defined?
>=20
> Dunno; is that something FreeBSD specific?  The comment in
> net/net_osdep.h that includes PSEUDO_SET in it may be of
> help.

That's very likely to be FreeBSD stuff.  Definitely not NetBSD stuff
anyway.

Remember that the NetBSD kernel doesn't include a linker, so modload(8)
spawns ld(1) which does the actual linking and then modload(8) copies
the resulting binary to the kernel.

--=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.

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

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

iQEVAwUBQxHXidgoQloHrPnoAQJg1Qf/ayQJMNYDpLpDsCwoAHY+J05KuhUzWV5o
nKHFNim2VBmMz9mOlKx7aU/mluJqV5BivHP448+rB+ZmfsYUOH0sr5GC21e/kOjZ
cBJrJMFJ7igNucO5OUvUwT4T8ML793hQUleL5TMbGrAjw6G4zVWSrMDqew3TMOCv
maX9NoZgfd7wJy6T7hyDtSVhT2Z8MJqZcmUs1JBkSaST6sqqb2xX7ylkTHjiB270
s1oN043QfAFO4Pv6/Sj7+T65ltN3MM4REBMtR5dePXjaX0hei0+9r2bxX7K5cDhB
XNOYuvKgo0RrtbuhpWe8LjGPqUmSjteEVLm8lBh1eJnTN0ZvQFu9ow==
=Rdjb
-----END PGP SIGNATURE-----

--rpOPesfUXqAMaEty--