ksyms.4 (210676) | ksyms.4 (233648) |
---|---|
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. --- 15 unchanged lines hidden (view full) --- 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.\" | 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. --- 15 unchanged lines hidden (view full) --- 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: head/share/man/man4/ksyms.4 210676 2010-07-31 12:14:28Z joel $ | 32.\" $FreeBSD: head/share/man/man4/ksyms.4 233648 2012-03-29 05:02:12Z eadler $ |
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 43The 44.Pa /dev/ksyms | 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 43The 44.Pa /dev/ksyms |
45character device provides a read-only interface to a snapshot of the kernel | 45character device provides a read-only interface to a snapshot of the kernel |
46symbol table. The in-kernel symbol manager is designed to be able to handle | 46symbol table. The in-kernel symbol manager is designed to be able to handle |
47many types of symbols tables, however, only | 47many types of symbols tables, however, only |
48.Xr elf 5 49symbol tables are supported by this device. The ELF format image contains two | 48.Xr elf 5 49symbol tables are supported by this device. The ELF format image contains two |
50sections: a symbol table and a corresponding string table. | 50sections: a symbol table and a corresponding string table. |
51.Bl -tag -width indent -offset indent 52.It Dv Symbol Table | 51.Bl -tag -width indent -offset indent 52.It Dv Symbol Table |
53The SYMTAB section contains the symbol table entries present in the current | 53The SYMTAB section contains the symbol table entries present in the current |
54running kernel, including the symbol table entries of any loaded modules. The 55symbols are ordered by the kernel module load time starting with kernel file 56symbols first, followed by the first loaded module's symbols and so on. 57.It Dv String Table 58The STRTAB section contains the symbol name strings from the kernel and any 59loaded modules that the symbol table entries reference. 60.El 61.Pp 62Elf formatted symbol table data read from the 63.Pa /dev/ksyms 64file represents the state of the kernel at the time when the device is opened. 65Since 66.Pa /dev/ksyms 67has no text or data, most of the fields are initialized to NULL. | 54running kernel, including the symbol table entries of any loaded modules. The 55symbols are ordered by the kernel module load time starting with kernel file 56symbols first, followed by the first loaded module's symbols and so on. 57.It Dv String Table 58The STRTAB section contains the symbol name strings from the kernel and any 59loaded modules that the symbol table entries reference. 60.El 61.Pp 62Elf formatted symbol table data read from the 63.Pa /dev/ksyms 64file represents the state of the kernel at the time when the device is opened. 65Since 66.Pa /dev/ksyms 67has no text or data, most of the fields are initialized to NULL. |
68The 69.Nm | 68The 69.Nm |
70driver does not block the loading or unloading of modules into the kernel | 70driver does not block the loading or unloading of modules into the kernel |
71while the | 71while the |
72.Pa /dev/ksyms 73file is open but may contain stale data. 74.Sh IOCTLS 75The 76.Xr ioctl 2 77command codes below are defined in 78.Aq Pa sys/ksyms.h . 79.Pp 80The (third) argument to the 81.Xr ioctl 2 82should be a pointer to the type indicated. 83.Bl -tag -width indent -offset indent 84.It Dv KIOCGSIZE (size_t) 85Returns the total size of the current symbol table. 86This can be used when allocating a buffer to make a copy of 87the kernel symbol table. 88.It Dv KIOCGADDR (void *) 89Returns the address of the kernel symbol table mapped in | 72.Pa /dev/ksyms 73file is open but may contain stale data. 74.Sh IOCTLS 75The 76.Xr ioctl 2 77command codes below are defined in 78.Aq Pa sys/ksyms.h . 79.Pp 80The (third) argument to the 81.Xr ioctl 2 82should be a pointer to the type indicated. 83.Bl -tag -width indent -offset indent 84.It Dv KIOCGSIZE (size_t) 85Returns the total size of the current symbol table. 86This can be used when allocating a buffer to make a copy of 87the kernel symbol table. 88.It Dv KIOCGADDR (void *) 89Returns the address of the kernel symbol table mapped in |
90the process memory. | 90the process memory. |
91.El 92.Sh FILES 93.Bl -tag -width /dev/ksymsX 94.It Pa /dev/ksyms 95.El 96.Sh ERRORS | 91.El 92.Sh FILES 93.Bl -tag -width /dev/ksymsX 94.It Pa /dev/ksyms 95.El 96.Sh ERRORS |
97An | 97An |
98.Xr open 2 99of 100.Pa /dev/ksyms | 98.Xr open 2 99of 100.Pa /dev/ksyms |
101will fail if: | 101will fail if: |
102.Bl -tag -width Er 103.It Bq Er EBUSY | 102.Bl -tag -width Er 103.It Bq Er EBUSY |
104The device is already open. A process must close | 104The device is already open. A process must close |
105.Pa /dev/ksyms | 105.Pa /dev/ksyms |
106before it can be opened again. | 106before it can be opened again. |
107.It Bq Er ENOMEM 108There is a resource shortage in the kernel. 109.It Bq Er ENXIO 110The driver was unsuccessful in creating a snapshot of the kernel symbol 111table. This may occur if the kernel was in the process of loading or | 107.It Bq Er ENOMEM 108There is a resource shortage in the kernel. 109.It Bq Er ENXIO 110The driver was unsuccessful in creating a snapshot of the kernel symbol 111table. This may occur if the kernel was in the process of loading or |
112unloading a module. | 112unloading 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 120A 121.Nm 122device exists in many different operating systems. 123This implementation is similar in function to the Solaris and NetBSD 124.Nm 125driver. 126.Pp 127The 128.Nm 129driver first appeared in 130.Fx 8.0 | 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 120A 121.Nm 122device exists in many different operating systems. 123This implementation is similar in function to the Solaris and NetBSD 124.Nm 125driver. 126.Pp 127The 128.Nm 129driver first appeared in 130.Fx 8.0 |
131to support | 131to support |
132.Xr lockstat 1 . 133.Sh AUTHORS 134The 135.Nm 136driver was written by 137.An Stacey Son 138.Aq sson@FreeBSD.org . 139.Sh BUGS | 132.Xr lockstat 1 . 133.Sh AUTHORS 134The 135.Nm 136driver was written by 137.An Stacey Son 138.Aq sson@FreeBSD.org . 139.Sh BUGS |
140Because files can be dynamically linked into the kernel at any time the symbol | 140Because files can be dynamically linked into the kernel at any time the symbol |
141information can vary. When you open the 142.Pa /dev/ksyms 143file, 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 145A process is only allowed to open the 146.Pa /dev/ksyms 147file once at a time. The process must close the 148.Pa /dev/ksyms 149before it is allowed to open it again. | 141information can vary. When you open the 142.Pa /dev/ksyms 143file, 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 145A process is only allowed to open the 146.Pa /dev/ksyms 147file once at a time. The process must close the 148.Pa /dev/ksyms 149before it is allowed to open it again. |
150.Pp | 150.Pp |
151The 152.Nm | 151The 152.Nm |
153driver uses the calling process' memory address space to store the snapshot. | 153driver uses the calling process' memory address space to store the snapshot. |
154.Xr ioctl 2 155can be used to get the memory address where the symbol table is stored to | 154.Xr ioctl 2 155can be used to get the memory address where the symbol table is stored to |
156save kernel memory. | 156save kernel memory. |
157.Xr mmap 2 | 157.Xr mmap 2 |
158may also be used but it will map it to another address. | 158may also be used but it will map it to another address. |