diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2002-11-18 02:48:17 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-11-18 02:48:17 -0800 |
| commit | a5508ddcd000a435baa37f61ef1bdfb490fcf3c0 (patch) | |
| tree | 8c231825fd939453a7dbbf1c4bd707b3adb3ae24 /scripts | |
| parent | 60c30d29536a741757c3f693ecea14fc0144b6da (diff) | |
[PATCH] kallsyms for new modules
Since I believe kallsyms is important, this reimplements it sanely,
using the current module infrastructure, and not using an external
kallsyms script.
FYI, the previous interface was:
int kallsyms_symbol_to_address(
const char *name, /* Name to lookup */
unsigned long *token, /* Which module to start with */
const char **mod_name, /* Set to module name or "kernel" */
unsigned long *mod_start, /* Set to start address of module */
unsigned long *mod_end, /* Set to end address of module */
const char **sec_name, /* Set to section name */
unsigned long *sec_start, /* Set to start address of section */
unsigned long *sec_end, /* Set to end address of section */
const char **sym_name, /* Set to full symbol name */
unsigned long *sym_start, /* Set to start address of symbol */
unsigned long *sym_end /* Set to end address of symbol */
);
The new one is:
/* Lookup an address. modname is set to NULL if it's in the kernel. */
const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset,
char **modname);
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kallsyms | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/kallsyms b/scripts/kallsyms new file mode 100644 index 000000000000..db057d0974dc --- /dev/null +++ b/scripts/kallsyms @@ -0,0 +1,40 @@ +#! /bin/sh +# Written by Rusty Russell <rusty@rustcorp.com.au> 2002. + +if [ $# -ne 2 ]; then + echo Usage: kallsyms vmlinux objfile >&2 + + echo Adds a .kallsyms section containing symbol info. + exit 1 +fi + +set -e + +# Clean up on exit. +trap "rm -f kallsyms.map kallsyms.c $2" 0 + +# Takes nm output from $1, produces a .c file on standard output. +encode_symbols() +{ + # First take addresses. + echo "unsigned long kallsyms_addresses[] = {" + sed 's/^[ ]*\([A-Fa-f0-9]*\).*/0x\1UL,/' < $1 + echo "};" + + # Now output size. + echo "unsigned long kallsyms_num_syms = `wc -l < $1`;" + + # Now output names. + echo "char kallsyms_names[] = "; + sed 's/^[ ]*[A-Fa-f0-9]*[ ]*.[ ]\(.*\)/"\1\\0"/' < $1 + echo ";" +} + +# FIXME: Use System.map as input, and regenerate each time in Makefile. +$NM $1 | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > kallsyms.map + +encode_symbols kallsyms.map > kallsyms.c +$CC $CFLAGS -c -o $2 kallsyms.c + +trap "rm -f kallsyms.map kallsyms.c" 0 +exit 0 |
