kdb
[Top] [All Lists]

An alternative source of kernel symbols

To: kdb@xxxxxxxxxxx
Subject: An alternative source of kernel symbols
From: Keith Owens <kaos@xxxxxxxxxx>
Date: Sat, 22 Apr 2000 22:53:30 +1000
Sender: owner-kdb@xxxxxxxxxxx
modutils 2.3.11 provides generic support for debuggers by loading a
complete set of non-stack symbols in the kernel and in modules.  This
is activated when the kernel is compiled with CONFIG_KALLSYMS[1].  As
proof of concept, I reworked kdb v0.6 against kernel 2.2.15pre19 and
kdb v1.0 against kernel 2.3.99-pre6-5 to use kallsyms instead of kdb's
own method of obtaining symbols.

Loading a complete non-stack symbol table is relatively expensive, it
adds 10-20% to the size of the kernel and modules.  The CONFIG_KALLSYMS
option should only be used when debugging.  The kallsyms data contains
a lot of data, for the kernel and for each module it lists

* The section names, start and end addresses.
* The symbol names, start and end addresses and the section each symbol
  belongs to.

Why this much data?  Because if you have the start address of the
section and the start and end of a symbol, you can get a clean
disassemble of a module with addresses that match your system by

  objdump -S -j <section_name> --adjust-vma=<section_start> \
        --start-address=<symbol_start> --stop-address=<symbol_end> \
        module.o

A similar command for the kernel, omit --adjust-vma because the kernel
is executable, not relocatable.

  objdump -S -j <section_name> \
        --start-address=<symbol_start> --stop-address=<symbol_end> \
        vmlinux

-S disassembles the section.  If you compiled the kernel with -g you
even get source and binary interleaved in the objdump listing.

As proof of concept for kallsyms, modutils/v2.3 contains

patch-2.2.15pre19-kallsyms.gz  
        Add CONFIG_KALLSYMS to kernel 2.2.15pre19.

patch-2.2.15pre19-kallsyms-kdb-v0.6.gz
        Add CONFIG_KALLSYMS + reworked SGI kdb v0.6 against kernel
        2.2.15pre19.

patch-2.3-99-pre6-5-kallsyms.bz2
        Add CONFIG_KALLSYMS to kernel 2.3-99-pre6-5.

patch-2.3-99-pre6-5-kallsyms-kdb-v1.0.bz2
        Add CONFIG_KALLSYMS + reworked SGI kdb v1.0 against kernel
       2.3-99-pre6-5.

* It uses kallsyms for its symbol table instead of the SGI symbol
  table.
* No fixed size for the symbol table and no need to ask the user for a
  size at compile time.
* Using the section data accurately verifies that an address falls
  within a kernel or module section instead of using the less reliable
  test on _[se]text and vmalloc areas.
* Every symbol printed is followed by the module name, the section
  start, the symbol start and end addresses.  Feed these addresses into
  objdump -S for a nice disassemble.

[1] CONFIG_KALLSYMS is not yet integrated into the kernel, whether it
    will be integrated depends on its usage.  If nobody uses it then I
    cannot persuade Linus to include it.


<Prev in Thread] Current Thread [Next in Thread>