2003-05-13 14:08:36 +04:00
|
|
|
.\" $NetBSD: ksyms.4,v 1.3 2003/05/13 10:08:36 wiz Exp $
|
2003-04-29 15:35:54 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
|
|
.\" 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 NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
|
|
|
.\"
|
|
|
|
.Dd April 29, 2003
|
|
|
|
.Dt KSYMS 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ksyms
|
2003-05-11 22:09:49 +04:00
|
|
|
.Nd kernel symbol table interface
|
2003-04-29 15:35:54 +04:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Cd "pseudo-device ksyms"
|
|
|
|
.Sh DESCRIPTION
|
2003-05-11 22:09:49 +04:00
|
|
|
The
|
|
|
|
.Pa /dev/ksyms
|
|
|
|
character device provides a read-only interface to the current
|
2003-05-13 14:08:36 +04:00
|
|
|
kernel symbol table.
|
|
|
|
It can be accessed either as a sequential
|
2003-05-11 22:09:49 +04:00
|
|
|
file, where it looks like an executable file but with zero-sized
|
|
|
|
text and data segments, or via
|
|
|
|
.Xr ioctl 2 .
|
|
|
|
.Pp
|
|
|
|
.Pa /dev/ksyms
|
|
|
|
represents the symbol table at the time when the device is opened,
|
2003-05-13 14:08:36 +04:00
|
|
|
and may not change until it is closed.
|
2003-05-11 22:09:49 +04:00
|
|
|
.Pp
|
2003-05-13 14:08:36 +04:00
|
|
|
The in-kernel symbol manager is designed to be able to handle
|
|
|
|
any type of symbol table.
|
|
|
|
However, only
|
2003-05-11 22:09:49 +04:00
|
|
|
.Xr elf 5
|
|
|
|
symbol tables are currently dealt with.
|
|
|
|
.Sh IOCTLS
|
|
|
|
The
|
|
|
|
.Xr ioctl 2
|
2003-05-13 14:08:36 +04:00
|
|
|
command codes below are defined in
|
|
|
|
.Aq Pa sys/ksyms.h .
|
2003-05-11 22:09:49 +04:00
|
|
|
.Pp
|
|
|
|
The (third) argument to the
|
|
|
|
.Xr ioctl 2
|
|
|
|
should be a pointer to the type indicated.
|
|
|
|
.Bl -tag -width indent -offset indent
|
2003-05-13 14:08:36 +04:00
|
|
|
.It Dv KIOCGSIZE (int)
|
2003-05-11 22:09:49 +04:00
|
|
|
Returns the total size of the current symbol table.
|
|
|
|
This should be used when allocating a buffer to read in the
|
|
|
|
whole symbol table to memory.
|
|
|
|
.It Dv KIOCGVALUE (struct ksyms_gsymbol)
|
2003-05-13 14:08:36 +04:00
|
|
|
Returns the value for the given symbol name in a symtab-independent
|
2003-05-11 22:09:49 +04:00
|
|
|
fashion.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct ksyms_gsymbol {
|
|
|
|
const char *kg_name;
|
|
|
|
unsigned long *kg_value;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The struct element
|
|
|
|
.Va kg_name
|
|
|
|
should be set to the name of the requested value, and the address that
|
|
|
|
.Va kg_value
|
|
|
|
points to will receive the symbol value.
|
|
|
|
.It Dv KIOCGSYMBOL (struct ksyms_gsymbol)
|
|
|
|
Returns the complete symbol for the given symbol name.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct ksyms_gsymbol {
|
|
|
|
const char *kg_name;
|
|
|
|
void *kg_sym;
|
2003-05-13 14:08:36 +04:00
|
|
|
};
|
2003-05-11 22:09:49 +04:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The struct element
|
|
|
|
.Va kg_name
|
|
|
|
should be set to the name of the requested symbol, and the found
|
|
|
|
symbol will be written to the
|
|
|
|
.Va kg_sym
|
2003-05-13 14:08:36 +04:00
|
|
|
address.
|
|
|
|
It is the callers responsibility to ensure that enough space
|
2003-05-11 22:09:49 +04:00
|
|
|
for the symbol is allocated.
|
|
|
|
.El
|
2003-05-13 14:08:36 +04:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /dev/ksymsX
|
|
|
|
.It Pa /dev/ksysms
|
|
|
|
.El
|
2003-04-29 15:35:54 +04:00
|
|
|
.Sh SEE ALSO
|
2003-05-11 22:09:49 +04:00
|
|
|
.Xr ioctl 2 ,
|
2003-05-13 14:08:36 +04:00
|
|
|
.Xr nlist 3 ,
|
|
|
|
.Xr elf 5
|
2003-05-11 22:09:49 +04:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
2003-05-13 14:08:36 +04:00
|
|
|
device exists in many different operating systems.
|
|
|
|
This implementation is modelled in function after Solaris
|
2003-05-11 22:09:49 +04:00
|
|
|
.Nm .
|
|
|
|
This
|
|
|
|
.Nm
|
|
|
|
driver was written by Anders Magnusson for
|
|
|
|
.Nx .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver first appeared in
|
|
|
|
.Nx 2.0 .
|
2003-04-29 15:35:54 +04:00
|
|
|
.Sh BUGS
|
2003-05-11 22:09:49 +04:00
|
|
|
No LKM modules can be loaded or unloaded while
|
|
|
|
.Pa /dev/ksyms
|
|
|
|
is open.
|