cf8a447bbcd5b1621d4edc36a69fe0ad384fe53f
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 203-kallsyms_uncompressed.patch
1 --- a/scripts/kallsyms.c
2 +++ b/scripts/kallsyms.c
3 @@ -58,6 +58,7 @@ static struct addr_range percpu_range =
4 static struct sym_entry *table;
5 static unsigned int table_size, table_cnt;
6 static int all_symbols = 0;
7 +static int uncompressed = 0;
8 static int absolute_percpu = 0;
9 static char symbol_prefix_char = '\0';
10 static unsigned long long kernel_start_addr = 0;
11 @@ -403,6 +404,9 @@ static void write_src(void)
12
13 free(markers);
14
15 + if (uncompressed)
16 + return;
17 +
18 output_label("kallsyms_token_table");
19 off = 0;
20 for (i = 0; i < 256; i++) {
21 @@ -461,6 +465,9 @@ static void *find_token(unsigned char *s
22 {
23 int i;
24
25 + if (uncompressed)
26 + return NULL;
27 +
28 for (i = 0; i < len - 1; i++) {
29 if (str[i] == token[0] && str[i+1] == token[1])
30 return &str[i];
31 @@ -533,6 +540,9 @@ static void optimize_result(void)
32 {
33 int i, best;
34
35 + if (uncompressed)
36 + return;
37 +
38 /* using the '\0' symbol last allows compress_symbols to use standard
39 * fast string functions */
40 for (i = 255; i >= 0; i--) {
41 @@ -703,7 +713,9 @@ int main(int argc, char **argv)
42 } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
43 const char *p = &argv[i][14];
44 kernel_start_addr = strtoull(p, NULL, 16);
45 - } else
46 + } else if (strcmp(argv[i], "--uncompressed") == 0)
47 + uncompressed = 1;
48 + else
49 usage();
50 }
51 } else if (argc != 1)
52 --- a/init/Kconfig
53 +++ b/init/Kconfig
54 @@ -1345,6 +1345,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
55 the unaligned access emulation.
56 see arch/parisc/kernel/unaligned.c for reference
57
58 +config KALLSYMS_UNCOMPRESSED
59 + bool "Keep kallsyms uncompressed"
60 + depends on KALLSYMS
61 + help
62 + Normally kallsyms contains compressed symbols (using a token table),
63 + reducing the uncompressed kernel image size. Keeping the symbol table
64 + uncompressed significantly improves the size of this part in compressed
65 + kernel images.
66 +
67 + Say N unless you need compressed kernel images to be small.
68 +
69 config HAVE_PCSPKR_PLATFORM
70 bool
71
72 --- a/scripts/link-vmlinux.sh
73 +++ b/scripts/link-vmlinux.sh
74 @@ -90,6 +90,10 @@ kallsyms()
75 kallsymopt="${kallsymopt} --absolute-percpu"
76 fi
77
78 + if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
79 + kallsymopt="${kallsymopt} --uncompressed"
80 + fi
81 +
82 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
83 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
84
85 --- a/kernel/kallsyms.c
86 +++ b/kernel/kallsyms.c
87 @@ -109,6 +109,11 @@ static unsigned int kallsyms_expand_symb
88 * For every byte on the compressed symbol data, copy the table
89 * entry for that byte.
90 */
91 +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
92 + memcpy(result, data + 1, len - 1);
93 + result += len - 1;
94 + len = 0;
95 +#endif
96 while (len) {
97 tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
98 data++;
99 @@ -141,6 +146,9 @@ tail:
100 */
101 static char kallsyms_get_symbol_type(unsigned int off)
102 {
103 +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
104 + return kallsyms_names[off + 1];
105 +#endif
106 /*
107 * Get just the first code, look it up in the token table,
108 * and return the first char from this token.