]> www.infradead.org Git - users/jedix/linux-maple.git/commit
kallsyms: add /proc/kallmodsyms
authorNick Alcock <nick.alcock@oracle.com>
Fri, 11 May 2012 20:21:33 +0000 (21:21 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 29 Jun 2015 21:40:24 +0000 (22:40 +0100)
commitf8dd5924eeb921c265a5d28e5099d7710945dc6a
tree52d154a2b2300b53ccddaa0bf851a42c58eea763
parent2a597d2b0c8b79bef74c24a5ebf631be76f8862c
kallsyms: add /proc/kallmodsyms

This procfile (controlled by CONFIG_KALLSYMS), introduces a new
/proc/kallmodsyms whose contents are the same as /proc/kallsyms, except that the
module name is provided even for built-in modules, as long as they could
potentially have been built as separate kernel modules.  DTrace will use it in
future to allow users to use the same module names in their D scripts regardless
of whether the modules are built-in or not in the kernel they happen to be
running.

This is done by scanning the object files named in the builtin.modules file
using libelf, extracting their function symbols, pruning out any symbols which
appear in more than one builtin module (since these are probably out-of-line
copies of inline functions in common kernel header files), then emitting the
names of all the modules in a new kallsyms_modules symbol and pointing at the
appropriate modules in a kallsyms_symbol_modules symbol which maps 1:1 to the
contents of kallsyms_addresses (thus, one kallsyms_symbol entry per kernel
symbol in /proc/kallsyms).  Always-built-in functions have a corresponding
kallsyms_symbol_modules index of zero.

This is not terribly space-efficient: the kallsyms_symbol_modules symbol is
quite large (~250K, mostly zeroes, four bytes per kernel symbol), but reducing
this requires some other way to signal that a symbol is not present in a module.
It is much smaller than even the compressed representation of the symbol names.

Possible future enhancements, low priority:
 - use a home-cooked hashtable rather than glib (pointless unless dwarf2ctf is
   similarly rejigged)
 - use nm rather than elfutils (liable to be quite a lot slower)
 - find a more robust way of detecting inlined functions, not fooled by
   out-of-line copies of inlined functions which happen to be used by
   only one module
 - shrink the kernel symbol space consumption, perhaps by using shorts rather
   than longs for the module offsets (65536Kb of module names should be enough
   for anybody)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Documentation/Changes
include/linux/kallsyms.h
kernel/kallsyms.c
scripts/Makefile
scripts/kallsyms.c