xref: /freebsd/share/man/man4/kld.4 (revision 7660b554bc59a07be0431c17e0e33815818baa69)
1.\" Copyright (c) 1993 Christopher G. Demetriou
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. The name of the author may not be used to endorse or promote products
13.\"    derived from this software without specific prior written permission
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd November 8, 1998
29.Dt KLD 4
30.Os
31.Sh NAME
32.Nm kld
33.Nd dynamic kernel linker facility
34.Sh DESCRIPTION
35The LKM (Loadable Kernel Modules) facility has been deprecated in
36.Fx 3.0
37and above in favor of the
38.Nm
39interface.
40This interface, like its
41predecessor, allows the system administrator to dynamically add and remove
42functionality from a running system.
43This ability also helps software
44developers to develop new parts of the kernel without constantly rebooting
45to test their changes.
46.Pp
47Various types of modules can be loaded into the system.
48There are several defined module types, listed below, which can
49be added to the system in a predefined way.
50In addition, there
51is a generic type, for which the module itself handles loading and
52unloading.
53.Pp
54The
55.Fx
56system makes extensive use of loadable kernel modules, and provides loadable
57versions of most file systems, the
58.Tn NFS
59client and server, all the screen-savers, and the
60.Tn iBCS2
61and
62.Tn Linux
63emulators.
64.Nm
65modules are placed by default in the
66.Pa /boot/kernel
67directory along with their matching kernel.
68.Pp
69The
70.Nm
71interface is used through the
72.Xr kldload 8 ,
73.Xr kldunload 8
74and
75.Xr kldstat 8
76programs.
77.Pp
78The
79.Xr kldload 8
80program can load either
81.Xr a.out 5
82or ELF formatted loadable modules.
83The
84.Xr kldunload 8
85program unloads any given loaded module, if no other module is dependent
86upon the given module.
87The
88.Xr kldstat 8
89program is used to check the status of the modules currently loaded into the
90system.
91.Sh "MODULE TYPES"
92.Bl -ohang
93.It Em "Device Driver modules"
94New block and character device
95drivers may be loaded into the system with
96.Nm .
97Device nodes for the loaded drivers are automatically created when a
98module is loaded and destroyed when it is unloaded by
99.Xr devfs 5 .
100You can specify userland programs that will run when new devices
101become available as a result of loading modules, or existing devices
102go away when modules are unloaded, by configuring
103.Xr devd 8 .
104.El
105.Sh FILES
106.Bl -tag -width /usr/include/sys/module.h -compact
107.It Pa /boot/kernel
108directory containing module binaries built for the kernel also
109residing in the directory.
110.It Pa /usr/include/sys/module.h
111file containing definitions required to compile a
112.Nm
113module
114.It Pa /usr/share/examples/kld
115example source code implementing a sample kld module
116.El
117.Sh SEE ALSO
118.Xr kldfind 2 ,
119.Xr kldfirstmod 2 ,
120.Xr kldload 2 ,
121.Xr kldnext 2 ,
122.Xr kldstat 2 ,
123.Xr kldunload 2 ,
124.Xr devfs 5 ,
125.Xr devd 8 ,
126.Xr kldload 8 ,
127.Xr kldstat 8 ,
128.Xr kldunload 8
129.Sh BUGS
130If a module B, is dependent on another module A, but is not compiled with
131module A as a dependency, then
132.Xr kldload 8
133fails to load module B, even if module A is already present in the system.
134.Pp
135If multiple modules are dependent on module A, and are compiled with module
136A as a dependency, then
137.Xr kldload 8
138loads an instance of module A when any of the modules are loaded.
139.Pp
140If a custom entry point is used for a module, and the module is compiled as
141an
142.Sq ELF
143binary, then
144.Xr kldload 8
145fails to execute the entry point.
146.Pp
147.Xr kldload 8
148returns the cryptic message
149.Sq Li "ENOEXEC (Exec format error)"
150for any error encountered while loading a module.
151.Pp
152When system internal interfaces change, old modules often cannot
153detect this, and such modules when loaded will often cause crashes or
154mysterious failures.
155.Sh HISTORY
156The
157.Nm
158facility appeared in
159.Fx 3.0
160and was designed as a replacement for the
161.Xr lkm 4
162facility, which was similar in functionality to the loadable kernel modules
163facility provided by
164.Tn SunOS
1654.1.3.
166.Sh AUTHORS
167The
168.Nm
169facility was originally implemented by
170.An Doug Rabson Aq dfr@FreeBSD.org .
171