1ksyms(7D) Devices ksyms(7D)
2
3
4
6 ksyms - kernel symbols
7
9 /dev/ksyms
10
11
13 The file /dev/ksyms is a character special file that allows read-only
14 access to an ELF format image containing two sections: a symbol table
15 and a corresponding string table. The contents of the symbol table
16 reflect the symbol state of the currently running kernel. You can
17 determine the size of the image with the fstat() system call. The rec‐
18 ommended method for accessing the /dev/ksyms file is by using the ELF
19 access library. See elf(3ELF) for details. If you are not familiar
20 with ELF format, see a.out(4).
21
22
23 /dev/ksyms is an executable for the processor on which you are access‐
24 ing it. It contains ELF program headers which describe the text and
25 data segment(s) in kernel memory. Since /dev/ksyms has no text or
26 data, the fields specific to file attributes are initialized to NULL.
27 The remaining fields describe the text or data segment(s) in kernel
28 memory.
29
30 Symbol table The SYMTAB section contains the symbol table entries
31 present in the currently running kernel. This section
32 is ordered as defined by the ELF definition with
33 locally-defined symbols first, followed by globally-
34 defined symbols. Within symbol type, the symbols are
35 ordered by kernel module load time. For example, the
36 kernel file symbols are first, followed by the first
37 module's symbols, and so on, ending with the symbols
38 from the last module loaded.
39
40 The section header index (st_shndx) field of each sym‐
41 bol entry in the symbol table is set to SHN_ABS,
42 because any necessary symbol relocations are performed
43 by the kernel link editor at module load time.
44
45
46 String table The STRTAB section contains the symbol name strings
47 that the symbol table entries reference.
48
49
51 kernel(1M), stat(2), elf(3ELF), kvm_open(3KVM), a.out(4), mem(7D)
52
54 The kernel is dynamically configured. It loads kernel modules when nec‐
55 essary. Because of this aspect of the system, the symbol information
56 present in the running system can vary from time to time, as kernel
57 modules are loaded and unloaded.
58
59
60 When you open the /dev/ksyms file, you have access to an ELF image
61 which represents a snapshot of the state of the kernel symbol informa‐
62 tion at that instant in time. While the /dev/ksyms file remains open,
63 kernel module autounloading is disabled, so that you are protected from
64 the possibility of acquiring stale symbol data. Note that new modules
65 can still be loaded, however. If kernel modules are loaded while you
66 have the /dev/ksyms file open, the snapshot held by you will not be
67 updated. In order to have access to the symbol information of the newly
68 loaded modules, you must first close and then reopen the /dev/ksyms
69 file. Be aware that the size of the /dev/ksyms file will have changed.
70 You will need to use the fstat() function (see stat(2)) to determine
71 the new size of the file.
72
73
74 Avoid keeping the /dev/ksyms file open for extended periods of time,
75 either by using kvm_open(3KVM) of the default namelist file or with a
76 direct open. There are two reasons why you should not hold /dev/ksyms
77 open. First, the system's ability to dynamically configure itself is
78 partially disabled by the locking down of loaded modules. Second, the
79 snapshot of symbol information held by you will not reflect the symbol
80 information of modules loaded after your initial open of /dev/ksyms.
81
82
83 Note that the ksyms driver is a loadable module, and that the kernel
84 driver modules are only loaded during an open system call. Thus it is
85 possible to run stat(2) on the /dev/ksyms file without causing the
86 ksyms driver to be loaded. In this case, the file size returned is
87 UNKNOWN_SIZE. A solution for this behavior is to first open the
88 /dev/ksyms file, causing the ksyms driver to be loaded (if necessary).
89 You can then use the file descriptor from this open in a fstat() system
90 call to get the file's size.
91
93 The kernel virtual memory access library (libkvm) routines use
94 /dev/ksyms as the default namelist file. See kvm_open(3KVM) for
95 details.
96
97
98
99SunOS 5.11 11 Dec 2000 ksyms(7D)