1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: kernel: add a config option for keeping the kallsyms table uncompressed, saving ~9kb kernel size after lzma on ar71xx
4 [john@phrozen.org: added to my upstream queue 30.12.2016]
5 lede-commit: e0e3509b5ce2ccf93d4d67ea907613f5f7ec2eed
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 init/Kconfig | 11 +++++++++++
9 kernel/kallsyms.c | 8 ++++++++
10 scripts/kallsyms.c | 12 ++++++++++++
11 scripts/link-vmlinux.sh | 4 ++++
12 4 files changed, 35 insertions(+)
16 @@ -1384,6 +1384,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
17 the unaligned access emulation.
18 see arch/parisc/kernel/unaligned.c for reference
20 +config KALLSYMS_UNCOMPRESSED
21 + bool "Keep kallsyms uncompressed"
24 + Normally kallsyms contains compressed symbols (using a token table),
25 + reducing the uncompressed kernel image size. Keeping the symbol table
26 + uncompressed significantly improves the size of this part in compressed
29 + Say N unless you need compressed kernel images to be small.
31 config HAVE_PCSPKR_PLATFORM
34 --- a/kernel/kallsyms.c
35 +++ b/kernel/kallsyms.c
36 @@ -77,6 +77,11 @@ static unsigned int kallsyms_expand_symb
37 * For every byte on the compressed symbol data, copy the table
38 * entry for that byte.
40 +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
41 + memcpy(result, data + 1, len - 1);
46 tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
48 @@ -109,6 +114,9 @@ tail:
50 static char kallsyms_get_symbol_type(unsigned int off)
52 +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
53 + return kallsyms_names[off + 1];
56 * Get just the first code, look it up in the token table,
57 * and return the first char from this token.
58 --- a/scripts/kallsyms.c
59 +++ b/scripts/kallsyms.c
60 @@ -58,6 +58,7 @@ static struct addr_range percpu_range =
61 static struct sym_entry **table;
62 static unsigned int table_size, table_cnt;
63 static int all_symbols;
64 +static int uncompressed;
65 static int absolute_percpu;
66 static int base_relative;
68 @@ -486,6 +487,9 @@ static void write_src(void)
75 output_label("kallsyms_token_table");
77 for (i = 0; i < 256; i++) {
78 @@ -537,6 +541,9 @@ static unsigned char *find_token(unsigne
85 for (i = 0; i < len - 1; i++) {
86 if (str[i] == token[0] && str[i+1] == token[1])
88 @@ -609,6 +616,9 @@ static void optimize_result(void)
95 /* using the '\0' symbol last allows compress_symbols to use standard
96 * fast string functions */
97 for (i = 255; i >= 0; i--) {
98 @@ -773,6 +783,8 @@ int main(int argc, char **argv)
100 else if (strcmp(argv[i], "--base-relative") == 0)
102 + else if (strcmp(argv[i], "--uncompressed") == 0)
107 --- a/scripts/link-vmlinux.sh
108 +++ b/scripts/link-vmlinux.sh
109 @@ -186,6 +186,10 @@ kallsyms()
110 kallsymopt="${kallsymopt} --base-relative"
113 + if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
114 + kallsymopt="${kallsymopt} --uncompressed"
118 ${NM} -n ${1} | scripts/kallsyms ${kallsymopt} > ${2}