KSYMS(4) | Device Drivers Manual | KSYMS(4) |
ksyms
— kernel
symbol table interface
pseudo-device ksyms
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.
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)KIOCGVALUE
(struct ksyms_gvalue)struct ksyms_gvalue { const char *kv_name; uint64_t kv_value; };
The struct member kv_name should be set to the name of the requested value, and upon return kv_value contains the symbol value.
KIOCGSYMBOL
(struct ksyms_gsymbol)struct ksyms_gsymbol { const char *kg_name; void *kg_sym; };
The struct member 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.
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.
July 27, 2024 | NetBSD 10.99 |