]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man4/ksyms.4
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / share / man / man4 / ksyms.4
1 .\" Copyright (c) 2008-2009 Stacey Son <sson@FreeBSD.org>
2 .\"     The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" $FreeBSD$
33 .\"
34 .Dd April 5, 2009
35 .Dt KSYMS 4
36 .Os
37 .Sh NAME
38 .Nm ksyms
39 .Nd kernel symbol table interface
40 .Sh SYNOPSIS
41 .Cd "device ksyms"
42 .Sh DESCRIPTION
43 The
44 .Pa /dev/ksyms
45 character device provides a read-only interface to a snapshot of the kernel
46 symbol table.  The in-kernel symbol manager is designed to be able to handle
47 many types of symbols tables, however, only
48 .Xr elf 5
49 symbol tables are supported by this device.  The ELF format image contains two
50 sections: a symbol table and a corresponding string table.
51 .Bl -tag -width indent -offset indent
52 .It Dv Symbol Table
53 The SYMTAB section contains the symbol table entries present in the current
54 running kernel, including the symbol table entries of any loaded modules. The
55 symbols are ordered by the kernel module load time starting with kernel file
56 symbols first, followed by the first loaded module's symbols and so on.
57 .It Dv String Table
58 The STRTAB section contains the symbol name strings from the kernel and any
59 loaded modules that the symbol table entries reference.
60 .El
61 .Pp
62 Elf formatted symbol table data read from the
63 .Pa /dev/ksyms
64 file represents the state of the kernel at the time when the device is opened.
65 Since
66 .Pa /dev/ksyms
67 has no text or data, most of the fields are initialized to NULL.
68 The
69 .Nm
70 driver does not block the loading or unloading of modules into the kernel
71 while the
72 .Pa /dev/ksyms
73 file is open but may contain stale data.
74 .Sh IOCTLS
75 The
76 .Xr ioctl 2
77 command codes below are defined in
78 .Aq Pa sys/ksyms.h .
79 .Pp
80 The (third) argument to the
81 .Xr ioctl 2
82 should be a pointer to the type indicated.
83 .Bl -tag -width indent -offset indent
84 .It Dv KIOCGSIZE (size_t)
85 Returns the total size of the current symbol table.
86 This can be used when allocating a buffer to make a copy of
87 the kernel symbol table.
88 .It Dv KIOCGADDR (void *)
89 Returns the address of the kernel symbol table mapped in
90 the process memory.
91 .El
92 .Sh FILES
93 .Bl -tag -width /dev/ksymsX
94 .It Pa /dev/ksyms
95 .El
96 .Sh ERRORS
97 An
98 .Xr open 2
99 of
100 .Pa /dev/ksyms
101 will fail if:
102 .Bl -tag -width Er
103 .It Bq Er EBUSY
104 The device is already open.  A process must close
105 .Pa /dev/ksyms
106 before it can be opened again.
107 .It Bq Er ENOMEM
108 There is a resource shortage in the kernel.
109 .It Bq Er ENXIO
110 The driver was unsuccessful in creating a snapshot of the kernel symbol
111 table.  This may occur if the kernel was in the process of loading or
112 unloading a module.
113 .El
114 .Sh SEE ALSO
115 .Xr ioctl 2 ,
116 .Xr nlist 3 ,
117 .Xr elf 5 ,
118 .Xr kldload 8
119 .Sh HISTORY
120 A
121 .Nm
122 device exists in many different operating systems.
123 This implementation is similar in function to the Solaris and NetBSD
124 .Nm
125 driver.
126 .Pp
127 The
128 .Nm
129 driver first appeared in
130 .Fx 8.0
131 to support
132 .Xr lockstat 1 .
133 .Sh AUTHORS
134 The
135 .Nm
136 driver was written by
137 .An Stacey Son
138 .Aq sson@FreeBSD.org .
139 .Sh BUGS
140 Because files can be dynamically linked into the kernel at any time the symbol
141 information can vary.  When you open the
142 .Pa /dev/ksyms
143 file, you have access to an ELF image which represents a snapshot of the state of the kernel symbol information at that instant in time. Keeping the device open does not block the loading or unloading of kernel modules.  To get a new snapshot you must close and re-open the device.
144 .Pp
145 A process is only allowed to open the
146 .Pa /dev/ksyms
147 file once at a time.  The process must close the
148 .Pa /dev/ksyms
149 before it is allowed to open it again.
150 .Pp
151 The
152 .Nm
153 driver uses the calling process' memory address space to store the snapshot.
154 .Xr ioctl 2
155 can be used to get the memory address where the symbol table is stored to
156 save kernel memory.
157 .Xr mmap 2
158 may also be used but it will map it to another address.