Search code examples
linuxlinux-kernelsymbolskbuild

Why does my /proc/kallsyms file not contain all the symbols in System.map?


I saw from this SO post that /proc/kallsyms should have the symbols of dynamically loaded modules as well as static code whereas System.map contains only the symbols of static code. However, when I cat /proc/kallsyms I seem to only have symbols in the text section of the kernel (T and t flags), save one or two symbols like

0000000000000000 D irq_stack_union
0000000000000000 D __per_cpu_start

On the other hand, in System.map I have symbols from many sections - essentially everything from /proc/kallsyms except loaded kernel module symbols.

To show the magnitude of this difference I used the wc command.

user@debian:~/$ cat /boot/System.map-3.2.0-4-amd64 | wc
  51256  153768 2117121
user@debian:~/$ cat /proc/kallsyms | wc
  29336   92637 1161409

What is the reason for this difference? Where are all of the data section related symbols in my /proc/kallsyms file?

Edit: As requested, here are the kallsyms configuration options.

user@debian:~$ cat /boot/config-3.2.0-4-amd64 | grep KALLSYMS
CONFIG_KALLSYMS=y
# CONFIG_KALLSYMS_ALL is not set

Solution

  • You don't have CONFIG_KALLSYMS_ALL set to y, therefore only text symbols are exported to /proc/kallsyms. Setting this to y and re-building the kernel (although not that simple to do) should solve the problem.

    I don't know if this is because you have an old kernel or some distro that disables it in their build. You could also try upgrading to a newer kernel. In my Debian 9 Linux v4.9 it seems to be enabled.