xref: /dragonfly/share/man/man4/kld.4 (revision a68e0df0)
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: src/share/man/man4/kld.4,v 1.5.2.6 2001/08/17 13:08:38 ru Exp $
27.\" $DragonFly: src/share/man/man4/kld.4,v 1.8 2008/09/02 11:50:46 matthias Exp $
28.\"
29.Dd August 6, 2009
30.Dt KLD 4
31.Os
32.Sh NAME
33.Nm kld
34.Nd dynamic kernel linker facility
35.Sh DESCRIPTION
36The LKM (Loadable Kernel Modules) facility has been deprecated in
37.Fx 3.0
38and above in favor of the
39.Nm
40interface.
41This interface, like its
42predecessor, allows the system administrator to dynamically add and remove
43functionality from a running system.
44This ability also helps software
45developers to develop new parts of the kernel without constantly rebooting
46to test their changes.
47.Pp
48Various types of modules can be loaded into the system.
49There are several defined module types, listed below, which can
50be added to the system in a predefined way.
51In addition, there
52is a generic type, for which the module itself handles loading and
53unloading.
54.Pp
55The
56.Dx
57system makes extensive use of loadable kernel modules, and provides loadable
58versions of most filesystems, the
59.Tn NFS
60client and server, all the screen-savers, and the
61.Tn Linux
62emulator.
63.Nm
64modules are placed by default in the
65.Pa /boot/modules
66directory.
67.Pp
68The
69.Nm
70interface is used through the
71.Xr kldload 8 ,
72.Xr kldunload 8
73and
74.Xr kldstat 8
75programs.
76.Pp
77The
78.Xr kldload 8
79program can load either
80.Xr a.out 5
81or ELF formatted loadable modules.
82The
83.Xr kldunload 8
84program unloads any given loaded module, if no other module is dependent
85upon the given module.
86The
87.Xr kldstat 8
88program is used to check the status of the modules currently loaded into the
89system.
90.Sh FILES
91.Bl -tag -width ".In sys/module.h" -compact
92.It Pa /boot/modules
93directory containing module binaries shipped with the system
94.It In sys/module.h
95file containing definitions required to compile a
96.Nm
97module
98.It Pa /usr/share/examples/kld
99example source code implementing a sample kld module
100.El
101.Sh SEE ALSO
102.Xr kldfind 2 ,
103.Xr kldfirstmod 2 ,
104.Xr kldload 2 ,
105.Xr kldnext 2 ,
106.Xr kldstat 2 ,
107.Xr kldunload 2 ,
108.Xr kldload 8 ,
109.Xr kldstat 8 ,
110.Xr kldunload 8
111.Sh HISTORY
112The
113.Nm
114facility appeared in
115.Fx 3.0
116and was designed as a replacement for the
117.Xr lkm 4
118facility, which was similar in functionality to the loadable kernel modules
119facility provided by
120.Tn SunOS
1214.1.3.
122.Sh AUTHORS
123The
124.Nm
125facility was originally implemented by
126.An Doug Rabson Aq dfr@FreeBSD.org .
127.Sh BUGS
128If a module B, is dependent on another module A, but is not compiled with
129module A as a dependency, then
130.Xr kldload 8
131fails to load module B, even if module A is already present in the system.
132.Pp
133If multiple modules are dependent on module A, and are compiled with module
134A as a dependency, then
135.Xr kldload 8
136loads an instance of module A when any of the modules are loaded.
137.Pp
138If a custom entry point is used for a module, and the module is compiled as
139an
140.Sq ELF
141binary, then
142.Xr kldload 8
143fails to execute the entry point.
144.Pp
145.Xr kldload 8
146returns the cryptic message
147.Sq Li "Exec format error"
148for any error encountered while loading a module.
149.Pp
150When system internal interfaces change, old modules often cannot
151detect this, and such modules when loaded will often cause crashes or
152mysterious failures.
153