xref: /netbsd-src/share/man/man4/ksyms.4 (revision aaf4ece63a859a04e37cf3a7229b5fab0157cc06)
1.\" $NetBSD: ksyms.4,v 1.4 2003/08/04 05:53:36 wiz Exp $
2.\"
3.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"        This product includes software developed by the NetBSD
17.\"        Foundation, Inc. and its contributors.
18.\" 4. Neither the name of The NetBSD Foundation nor the names of its
19.\"    contributors may be used to endorse or promote products derived
20.\"    from this software without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32.\" POSSIBILITY OF SUCH DAMAGE.
33.\"
34.Dd April 29, 2003
35.Dt KSYMS 4
36.Os
37.Sh NAME
38.Nm ksyms
39.Nd kernel symbol table interface
40.Sh SYNOPSIS
41.Cd "pseudo-device ksyms"
42.Sh DESCRIPTION
43The
44.Pa /dev/ksyms
45character device provides a read-only interface to the current
46kernel symbol table.
47It can be accessed either as a sequential
48file, where it looks like an executable file but with zero-sized
49text and data segments, or via
50.Xr ioctl 2 .
51.Pp
52.Pa /dev/ksyms
53represents the symbol table at the time when the device is opened,
54and may not change until it is closed.
55.Pp
56The in-kernel symbol manager is designed to be able to handle
57any type of symbol table.
58However, only
59.Xr elf 5
60symbol tables are currently dealt with.
61.Sh IOCTLS
62The
63.Xr ioctl 2
64command codes below are defined in
65.Aq Pa sys/ksyms.h .
66.Pp
67The (third) argument to the
68.Xr ioctl 2
69should be a pointer to the type indicated.
70.Bl -tag -width indent -offset indent
71.It Dv KIOCGSIZE (int)
72Returns the total size of the current symbol table.
73This should be used when allocating a buffer to read in the
74whole symbol table to memory.
75.It Dv KIOCGVALUE (struct ksyms_gsymbol)
76Returns the value for the given symbol name in a symtab-independent
77fashion.
78.Bd -literal -offset indent
79struct ksyms_gsymbol {
80	const char *kg_name;
81	unsigned long *kg_value;
82};
83.Ed
84.Pp
85The struct element
86.Va kg_name
87should be set to the name of the requested value, and the address that
88.Va kg_value
89points to will receive the symbol value.
90.It Dv KIOCGSYMBOL (struct ksyms_gsymbol)
91Returns the complete symbol for the given symbol name.
92.Bd -literal -offset indent
93struct ksyms_gsymbol {
94	const char *kg_name;
95        void *kg_sym;
96};
97.Ed
98.Pp
99The struct element
100.Va kg_name
101should be set to the name of the requested symbol, and the found
102symbol will be written to the
103.Va kg_sym
104address.
105It is the callers responsibility to ensure that enough space
106for the symbol is allocated.
107.El
108.Sh FILES
109.Bl -tag -width /dev/ksymsX
110.It Pa /dev/ksyms
111.El
112.Sh SEE ALSO
113.Xr ioctl 2 ,
114.Xr nlist 3 ,
115.Xr elf 5
116.Sh HISTORY
117A
118.Nm
119device exists in many different operating systems.
120This implementation is modelled in function after Solaris
121.Nm .
122This
123.Nm
124driver was written by Anders Magnusson for
125.Nx .
126.Pp
127The
128.Nm
129driver first appeared in
130.Nx 2.0 .
131.Sh BUGS
132No LKM modules can be loaded or unloaded while
133.Pa /dev/ksyms
134is open.
135