The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
$FreeBSD: releng/10.2/share/man/man4/ksyms.4 233648 2012-03-29 05:02:12Z eadler $
.Dd April 5, 2009 .Dt KSYMS 4 .Os .Sh NAME .Nm ksyms .Nd kernel symbol table interface .Sh SYNOPSIS .Cd "device ksyms" .Sh DESCRIPTION The
a /dev/ksyms character device provides a read-only interface to a snapshot of the kernel symbol table. The in-kernel symbol manager is designed to be able to handle many types of symbols tables, however, only .Xr elf 5 symbol tables are supported by this device. The ELF format image contains two sections: a symbol table and a corresponding string table. l -tag -width indent -offset indent t Dv Symbol Table The SYMTAB section contains the symbol table entries present in the current running kernel, including the symbol table entries of any loaded modules. The symbols are ordered by the kernel module load time starting with kernel file symbols first, followed by the first loaded module's symbols and so on. t Dv String Table The STRTAB section contains the symbol name strings from the kernel and any loaded modules that the symbol table entries reference. .El
p Elf formatted symbol table data read from the
a /dev/ksyms file represents the state of the kernel at the time when the device is opened. Since
a /dev/ksyms has no text or data, most of the fields are initialized to NULL. The .Nm driver does not block the loading or unloading of modules into the kernel while the
a /dev/ksyms file is open but may contain stale data. .Sh IOCTLS The .Xr ioctl 2 command codes below are defined in .Aq Pa sys/ksyms.h .
p The (third) argument to the .Xr ioctl 2 should be a pointer to the type indicated. l -tag -width indent -offset indent t Dv KIOCGSIZE (size_t) Returns the total size of the current symbol table. This can be used when allocating a buffer to make a copy of the kernel symbol table. t Dv KIOCGADDR (void *) Returns the address of the kernel symbol table mapped in the process memory. .El .Sh FILES l -tag -width /dev/ksymsX t Pa /dev/ksyms .El .Sh ERRORS An .Xr open 2 of
a /dev/ksyms will fail if: l -tag -width Er t Bq Er EBUSY The device is already open. A process must close
a /dev/ksyms before it can be opened again. t Bq Er ENOMEM There is a resource shortage in the kernel. t Bq Er ENXIO The driver was unsuccessful in creating a snapshot of the kernel symbol table. This may occur if the kernel was in the process of loading or unloading a module. .El .Sh SEE ALSO .Xr ioctl 2 , .Xr nlist 3 , .Xr elf 5 , .Xr kldload 8 .Sh HISTORY A .Nm device exists in many different operating systems. This implementation is similar in function to the Solaris and NetBSD .Nm driver.
p The .Nm driver first appeared in .Fx 8.0 to support .Xr lockstat 1 . .Sh AUTHORS The .Nm driver was written by .An Stacey Son .Aq sson@FreeBSD.org . .Sh BUGS Because files can be dynamically linked into the kernel at any time the symbol information can vary. When you open the
a /dev/ksyms 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.
p A process is only allowed to open the
a /dev/ksyms file once at a time. The process must close the
a /dev/ksyms before it is allowed to open it again.
p The .Nm driver uses the calling process' memory address space to store the snapshot. .Xr ioctl 2 can be used to get the memory address where the symbol table is stored to save kernel memory. .Xr mmap 2 may also be used but it will map it to another address.