a /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 .Xr ioctl 2 .
p
a /dev/ksyms represents the symbol table at the time when the device is opened, and may not change until it is closed.
p The in-kernel symbol manager is designed to be able to handle any type of symbol table. However, only .Xr elf 5 symbol tables are currently dealt with. .Sh IOCTLS The .Xr ioctl 2 command codes below are defined in n sys/ksyms.h .
p The (third) argument to the .Xr ioctl 2 should be a pointer to the type indicated. l -tag -width Dv -offset indent t Dv KIOCGSIZE Pq Vt 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. t Dv KIOCGVALUE Pq Vt struct ksyms_gvalue Returns the value for the given symbol name in a symtab-independent fashion. d -literal -offset indent struct ksyms_gvalue { const char *kv_name; uint64_t kv_value; }; .Ed
p The struct member .Fa kv_name should be set to the name of the requested value, and upon return .Fa kv_value contains the symbol value. t Dv KIOCGSYMBOL Pq Vt struct ksyms_gsymbol Returns the complete symbol for the given symbol name. d -literal -offset indent struct ksyms_gsymbol { const char *kg_name; void *kg_sym; }; .Ed
p The struct member .Fa kg_name should be set to the name of the requested symbol, and the found symbol will be written to the .Fa kg_sym address. It is the callers responsibility to ensure that enough space for the symbol is allocated. .El .Sh FILES l -tag -width Pa t Pa /dev/ksyms .El .Sh SEE ALSO .Xr ioctl 2 , .Xr nlist 3 , .Xr elf 5 .Sh HISTORY A .Nm device exists in many different operating systems. This implementation is modelled in function after Solaris .Nm . This .Nm driver was written by Anders Magnusson for .Nx .
p The .Nm driver first appeared in .Nx 2.0 .