1 .\" Copyright (c) 2000 Keith Owens <kaos@ocs.com.au>
2 .\" This program is distributed according to the Gnu General Public License.
3 .\" See the file COPYING in the kernel source directory.
5 .TH KALLSYMS 8 "January 31, 2002" Linux "Linux Module Support"
7 kallsyms \- Extract all kernel symbols for debugging
10 [\-Vh] kernel_filename
14 extracts all the non-stack symbols from a kernel and builds a data blob
15 that can be linked into that kernel for use by debuggers.
17 A normal kernel only exports symbols that are used by modules.
18 For debugging you may want a list of all the non-stack symbols, not
19 just the exported ones.
21 extracts all sections and symbols from a kernel, constructs a list of
22 the sections, symbols and their addresses and writes a relocatable
23 object containing just the __kallsyms section.
24 After the __kallsyms section is linked into the kernel and the kernel
25 has been booted, any debugger can use the data in the __kallsyms
26 section to get better symbol resolution.
28 For example, a debugger can use the __kallsyms data to resolve a kernel
32 The owning kernel or module.
34 The section within the owning code.
41 Display a summary of options and exit.
43 .BR \-V ", " \-\-version
44 Display the version of \fBkallsyms\fR and exit.
47 To create a kernel containing an accurate __kallsyms section, you have
48 to make four linker passes instead of the normal single link step.
49 kallsyms and the linker are fast, the three extra steps take a few
52 The initial build of the kernel, without any __kallsyms data.
53 Run \fBkallsyms\fR against the output of this link, creating a relocatable
54 object which contains all the sections and symbols in the raw kernel.
56 Link the kernel again, this time including the \fBkallsyms\fR output from
58 Adding the __kallsyms section changes the number of sections and many
59 of the kernel symbol offsets so run \fBkallsyms\fR again against the second
60 link, again saving the relocatable output.
62 Link the kernel again, this time including the \fBkallsyms\fR output from
64 Run \fBkallsyms\fR against the latest version of the kernel.
65 The size and position of the __kallsyms section on this run is now
66 stable, none of the kernel sections or symbols will change after this
68 The \fBkallsyms\fR output contains the final values of the kernel symbols.
70 Link the final kernel, including the \fBkallsyms\fR output from step (3).
73 The __kallsyms section is a bit unusual.
74 It deliberately has no relocatable data, all "pointers" are represented
75 as byte offsets into the section or as absolute numbers.
76 This means it can be stored anywhere without relocation problems.
77 In particular it can be stored within a kernel image, it can be stored
78 separately from the kernel image, it can be appended to a module just
79 before loading, it can be stored in a separate area, etc.
81 \fI/usr/include/sys/kallsyms.h\fR contains the mappings for the __kallsyms
88 Total size of the __kallsyms data, including strings.
91 This only included sections which are loaded into memory.
93 Offset to the first section entry from start of the __kallsyms header.
95 Size of each section entry, excluding the name string.
99 Offset to the first symbol entry from the start of the __kallsyms
102 Size of each symbol entry, excluding the name string.
104 Offset to the first string from the start of the __kallsyms header.
106 Start address of the first section[1].
108 End address of the last section[1].
112 One entry per loaded section.
113 Since __kallsyms is a loaded section, if the input file contains a
114 __kallsyms section then it is included in this list.
117 Start of the section within the kernel[1].
121 Offset to the name of section, from the start of the __kallsyms
124 Section flags, from the original Elf section.
128 One per symbol in the input file.
129 Only symbols that fall within loaded sections are stored.
132 Offset to the __kallsyms section entry that this symbol falls within.
133 The offset is from the start of the __kallsyms section entries.
135 Address of the symbol within the kernel[1].
136 The symbols are sorted in ascending order on this field.
138 Offset to the name of symbol, from the start of the __kallsyms strings.
142 A set of NUL terminated strings.
143 Each name is referenced using an offset from the start of the
144 __kallsyms string area.
147 These fields are exceptions to the "everything is an offset" rule.
148 They contain absolute addresses within the kernel.
152 Initial version by Keith Owens <kaos@ocs.com.au>, April 2000