Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ksyms(4) [netbsd man page]

KSYMS(4)						   BSD Kernel Interfaces Manual 						  KSYMS(4)

NAME
ksyms -- kernel symbol table interface SYNOPSIS
pseudo-device ksyms DESCRIPTION
The /dev/ksyms character device provides a read-only interface to the current kernel symbol table. It can be accessed either as a sequential file, where it looks like an executable file but with zero-sized text and data segments, or via ioctl(2). /dev/ksyms represents the symbol table at the time when the device is opened, and may not change until it is closed. The in-kernel symbol manager is designed to be able to handle any type of symbol table. However, only elf(5) symbol tables are currently dealt with. IOCTLS
The ioctl(2) command codes below are defined in <sys/ksyms.h>. The (third) argument to the ioctl(2) should be a pointer to the type indicated. KIOCGSIZE (int) 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. KIOCGVALUE (struct ksyms_gsymbol) Returns the value for the given symbol name in a symtab-independent fashion. struct ksyms_gsymbol { const char *kg_name; unsigned long *kg_value; }; The struct element kg_name should be set to the name of the requested value, and the address that kg_value points to will receive the symbol value. KIOCGSYMBOL (struct ksyms_gsymbol) Returns the complete symbol for the given symbol name. struct ksyms_gsymbol { const char *kg_name; void *kg_sym; }; The struct element kg_name should be set to the name of the requested symbol, and the found symbol will be written to the kg_sym address. It is the callers responsibility to ensure that enough space for the symbol is allocated. FILES
/dev/ksyms SEE ALSO
ioctl(2), nlist(3), elf(5) HISTORY
A ksyms device exists in many different operating systems. This implementation is modelled in function after Solaris ksyms. This ksyms driver was written by Anders Magnusson for NetBSD. The ksyms driver first appeared in NetBSD 2.0. BSD
November 12, 2008 BSD

Check Out this Related Man Page

KSYMS(4)                                                   BSD Kernel Interfaces Manual                                                   KSYMS(4)

NAME
ksyms -- kernel symbol table interface SYNOPSIS
device ksyms DESCRIPTION
The /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 elf(5) symbol tables are supported by this device. The ELF format image contains two sections: a symbol table and a corresponding string table. 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. String Table The STRTAB section contains the symbol name strings from the kernel and any loaded modules that the symbol table entries refer- ence. Elf formated symbol table data read from the /dev/ksyms file represents the state of the kernel at the time when the device is opened. Since /dev/ksyms has no text or data, most of the fields are initialized to NULL. The ksyms driver does not block the loading or unloading of mod- ules into the kernel while the /dev/ksyms file is open but may contain stale data. IOCTLS
The ioctl(2) command codes below are defined in <sys/ksyms.h>. The (third) argument to the ioctl(2) should be a pointer to the type indicated. 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. KIOCGADDR (void *) Returns the address of the kernel symbol table mapped in the process memory. FILES
/dev/ksyms ERRORS
An open(2) of /dev/ksyms will fail if: [EBUSY] The device is already open. A process must close /dev/ksyms before it can be opened again. [ENOMEM] There is a resource shortage in the kernel. [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. SEE ALSO
ioctl(2), nlist(3), elf(5), kldload(8) HISTORY
A ksyms device exists in many different operating systems. This implementation is similar in function to the Solaris and NetBSD ksyms driver. The ksyms driver first appeared in FreeBSD 8.0 to support lockstat(1). BUGS
Because files can be dynamically linked into the kernel at any time the symbol information can vary. When you open the /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. A process is only allowed to open the /dev/ksyms file once at a time. The process must close the /dev/ksyms before it is allowed to open it again. The ksyms driver uses the calling process' memory address space to store the snapshot. ioctl(2) can be used to get the memory address where the symbol table is stored to save kernel memory. mmap(2) may also be used but it will map it to another address. AUTHORS
The ksyms driver was written by Stacey Son <sson@freebsd.org>. BSD April 5, 2009 BSD
Man Page