diff options
| author | Andi Kleen <ak@muc.de> | 2002-12-25 09:46:32 -0600 |
|---|---|---|
| committer | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2002-12-25 09:46:32 -0600 |
| commit | fccef669d1d489d675fd6a8ae5fb87cac72a54d6 (patch) | |
| tree | 2593647c42aa2ece907411e46de79d3ea72367ec /kernel | |
| parent | a70441972d23b7165fe1f41a7925c4b3dea11f5f (diff) | |
kbuild: Stem compression for kallsyms
This patch implements simple stem compression for the kallsyms symbol
table. Each symbol has as first byte a count on how many characters
are identical to the previous symbol. This compresses the often
common repetive prefixes (like subsys_) fairly effectively.
On a fairly full featured monolithic i386 kernel this saves about 60k in
the kallsyms symbol table.
The changes are very simple, so the 60k are not shabby.
One visible change is that the caller of kallsyms_lookup has to pass in
a buffer now, because it has to be modified. I added an arbitary
127 character limit to it.
Still >210k left in the symbol table unfortunately. Another idea would be to
delta encode the addresses in 16bits (functions are all likely to be smaller
than 64K). This would especially help on 64bit hosts. Not done yet, however.
No, before someone asks, I don't want to use zlib for that. Far too fragile
during an oops and overkill too and it would require to link it into all
kernels.
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/kallsyms.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index bb880ba4e776..b2d21f78e229 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -4,6 +4,7 @@ * Rewritten and vastly simplified by Rusty Russell for in-kernel * module loader: * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation + * Stem compression by Andi Kleen. */ #include <linux/kallsyms.h> #include <linux/module.h> @@ -22,7 +23,7 @@ extern char _stext[], _etext[]; const char *kallsyms_lookup(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, - char **modname) + char **modname, char *namebuf) { unsigned long i, best = 0; @@ -30,6 +31,8 @@ const char *kallsyms_lookup(unsigned long addr, if ((void *)kallsyms_addresses == &kallsyms_dummy) BUG(); + namebuf[127] = 0; + if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) { unsigned long symbol_end; char *name = kallsyms_names; @@ -42,8 +45,11 @@ const char *kallsyms_lookup(unsigned long addr, } /* Grab name */ - for (i = 0; i < best; i++) + for (i = 0; i < best; i++) { + ++name; + strncpy(namebuf + name[-1], name, 127); name += strlen(name)+1; + } /* Base symbol size on next symbol. */ if (best + 1 < kallsyms_num_syms) @@ -54,7 +60,7 @@ const char *kallsyms_lookup(unsigned long addr, *symbolsize = symbol_end - kallsyms_addresses[best]; *modname = NULL; *offset = addr - kallsyms_addresses[best]; - return name; + return namebuf; } return module_address_lookup(addr, symbolsize, offset, modname); @@ -66,8 +72,9 @@ void __print_symbol(const char *fmt, unsigned long address) char *modname; const char *name; unsigned long offset, size; + char namebuf[128]; - name = kallsyms_lookup(address, &size, &offset, &modname); + name = kallsyms_lookup(address, &size, &offset, &modname, namebuf); if (!name) { char addrstr[sizeof("0x%lx") + (BITS_PER_LONG*3/10)]; |
