Skip to contentSkip to conversation

do not save thousands of useless symbols in KALLSYMS kernels

PATCH In review Denis Vlasenko 2 participants 3 messages Aug 11, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do not save thousands of useless symbols in KALLSYMS kernels

Sample of my kernel's mostly useless symbols
(starting_with:# of symbols):

__func__: 624
__vendorstr_: 1760
__pci_fixup_PCI_: 116
__ksymtab_: 2597
__kstrtab_: 2597
__kcrctab_: 2597
__initcall_: 236
__devicestr_: 4686
__devices_: 1760
Total: 16973
Lines in System.map: 39735

Excluding them from in-kernel symbol table saves ~300kb:

text data bss dec hex filename

4337710 1054414  259296 5651420  563bdc vmlinux.carrier1 - w/o KALLSYMS
4342068 1296046  259296 5897410  59fcc2 vmlinux - with KALLSYMS+patch
4341948 1607634  259296 6208878  5ebd6e vmlinux.carrier - with KALLSYMS
        ^^^^^^^

--
vda

scripts/kallsyms.c renamed from scripts/kallsyms.c.org +26 -3
@@ -36,7 +36,7 @@
 
 /* we use only a subset of the complete symbol table to gather the token count,
  * to speed up compression, at the expense of a little compression ratio */
-#define WORKING_SET		1024
+#define WORKING_SET		(1024*4)
 
 /* first find the best token only on the list of tokens that would profit more
  * than GOOD_BAD_THRESHOLD. Only if this list is empty go to the "bad" list.
@@ -102,11 +102,34 @@ usage(void)
  * This ignores the intensely annoying "mapping symbols" found
  * in ARM ELF files: $a, $t and $d.
  */
+/*
+__func__: 624
+__vendorstr_: 1760
+__pci_fixup_PCI_: 116
+__ksymtab_: 2597
+__kstrtab_: 2597
+__kcrctab_: 2597
+__initcall_: 236
+__devicestr_: 4686
+__devices_: 1760
+Total: 16973
+Lines in System.map: 39735
+*/
 static inline int
 is_arm_mapping_symbol(const char *str)
 {
-	return str[0] == '$' && strchr("atd", str[1])
-	       && (str[2] == '\0' || str[2] == '.');
+	return (str[0] == '$' && strchr("atd", str[1])
+	       && (str[2] == '\0' || str[2] == '.')
+	)
+	|| (0 == strncmp(str, "__ksymtab_", sizeof("__ksymtab_")-1))
+	|| (0 == strncmp(str, "__kstrtab_", sizeof("__kstrtab_")-1))
+	|| (0 == strncmp(str, "__kcrctab_", sizeof("__kcrctab_")-1))
+	|| (0 == strncmp(str, "__devices_", sizeof("__devices_")-1))
+	|| (0 == strncmp(str, "__devicestr_", sizeof("__devicestr_")-1))
+	|| (0 == strncmp(str, "__vendorstr_", sizeof("__vendorstr_")-1))
+	|| (0 == strncmp(str, "__pci_fixup_PCI_", sizeof("__pci_fixup_PCI_")-1))
+	|| (0 == strncmp(str, "__func__", sizeof("__func__")-1))
+	;
 }
 
 static int
#1 lore raw
Quoted 15 lines · Denis Vlasenko

Sample of my kernel's mostly useless symbols
(starting_with:# of symbols):

__func__: 624
__vendorstr_: 1760
__pci_fixup_PCI_: 116
__ksymtab_: 2597
__kstrtab_: 2597
__kcrctab_: 2597
__initcall_: 236
__devicestr_: 4686
__devices_: 1760
Total: 16973
Lines in System.map: 39735

Quoted 7 lines

Excluding them from in-kernel symbol table saves ~300kb:

text data bss dec hex filename

4337710 1054414  259296 5651420  563bdc vmlinux.carrier1 - w/o KALLSYMS
4342068 1296046  259296 5897410  59fcc2 vmlinux - with KALLSYMS+patch
4341948 1607634  259296 6208878  5ebd6e vmlinux.carrier - with KALLSYMS
        ^^^^^^^

Hummm.... these symbols should only go in if you config KALLSYMS_ALL. Are you sure your configuration doesn't have KALLSYMS_ALL enabled?

If it does, it seems like the correct behavior to include all symbols if you specified that you wanted _all_ symbols :)

By the way, there is a completely different version of scripts/kallsyms.c in -mm that you might want to look at. It will probably go in after 2.6.13 is out.

Signature · 5 lines
Paulo Marques - www.grupopie.com

It is a mistake to think you can solve any major problems
just with potatoes.
Douglas Adams
#2 lore raw
Quoted 18 lines · Paulo Marques
Quoted 17 lines · Denis Vlasenko

Sample of my kernel's mostly useless symbols
(starting_with:# of symbols):

__func__: 624
__vendorstr_: 1760
__pci_fixup_PCI_: 116
__ksymtab_: 2597
__kstrtab_: 2597
__kcrctab_: 2597
__initcall_: 236
__devicestr_: 4686
__devices_: 1760
Total: 16973
Lines in System.map: 39735

Excluding them from in-kernel symbol table saves ~300kb:

Quoted 8 lines
Quoted 5 lines

text data bss dec hex filename

4337710 1054414  259296 5651420  563bdc vmlinux.carrier1 - w/o KALLSYMS
4342068 1296046  259296 5897410  59fcc2 vmlinux - with KALLSYMS+patch
4341948 1607634  259296 6208878  5ebd6e vmlinux.carrier - with KALLSYMS
        ^^^^^^^

Hummm.... these symbols should only go in if you config KALLSYMS_ALL. Are you sure your configuration doesn't have KALLSYMS_ALL enabled?

Yes, it has...
--
vda