2022-10-18 20:26:34 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
|
|
|
Subject: kernel: add a config option for keeping the kallsyms table uncompressed, saving ~9kb kernel size after lzma on ar71xx
|
|
|
|
|
|
|
|
[john@phrozen.org: added to my upstream queue 30.12.2016]
|
|
|
|
lede-commit: e0e3509b5ce2ccf93d4d67ea907613f5f7ec2eed
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
|
|
---
|
|
|
|
init/Kconfig | 11 +++++++++++
|
|
|
|
kernel/kallsyms.c | 8 ++++++++
|
|
|
|
scripts/kallsyms.c | 12 ++++++++++++
|
|
|
|
scripts/link-vmlinux.sh | 4 ++++
|
|
|
|
4 files changed, 35 insertions(+)
|
|
|
|
|
|
|
|
--- a/init/Kconfig
|
|
|
|
+++ b/init/Kconfig
|
2024-02-23 20:40:12 +00:00
|
|
|
@@ -1491,6 +1491,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
|
2022-10-18 20:26:34 +00:00
|
|
|
the unaligned access emulation.
|
|
|
|
see arch/parisc/kernel/unaligned.c for reference
|
|
|
|
|
|
|
|
+config KALLSYMS_UNCOMPRESSED
|
|
|
|
+ bool "Keep kallsyms uncompressed"
|
|
|
|
+ depends on KALLSYMS
|
|
|
|
+ help
|
|
|
|
+ Normally kallsyms contains compressed symbols (using a token table),
|
|
|
|
+ reducing the uncompressed kernel image size. Keeping the symbol table
|
|
|
|
+ uncompressed significantly improves the size of this part in compressed
|
|
|
|
+ kernel images.
|
|
|
|
+
|
|
|
|
+ Say N unless you need compressed kernel images to be small.
|
|
|
|
+
|
|
|
|
config HAVE_PCSPKR_PLATFORM
|
|
|
|
bool
|
|
|
|
|
|
|
|
--- a/kernel/kallsyms.c
|
|
|
|
+++ b/kernel/kallsyms.c
|
2023-05-22 16:07:49 +00:00
|
|
|
@@ -69,6 +69,11 @@ static unsigned int kallsyms_expand_symb
|
2022-10-18 20:26:34 +00:00
|
|
|
* For every byte on the compressed symbol data, copy the table
|
|
|
|
* entry for that byte.
|
|
|
|
*/
|
|
|
|
+#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
|
|
|
|
+ memcpy(result, data + 1, len - 1);
|
|
|
|
+ result += len - 1;
|
|
|
|
+ len = 0;
|
|
|
|
+#endif
|
|
|
|
while (len) {
|
|
|
|
tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
|
|
|
|
data++;
|
2023-05-22 16:07:49 +00:00
|
|
|
@@ -101,6 +106,9 @@ tail:
|
2022-10-18 20:26:34 +00:00
|
|
|
*/
|
|
|
|
static char kallsyms_get_symbol_type(unsigned int off)
|
|
|
|
{
|
|
|
|
+#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
|
|
|
|
+ return kallsyms_names[off + 1];
|
|
|
|
+#endif
|
|
|
|
/*
|
|
|
|
* Get just the first code, look it up in the token table,
|
|
|
|
* and return the first char from this token.
|
|
|
|
--- a/scripts/kallsyms.c
|
|
|
|
+++ b/scripts/kallsyms.c
|
2023-07-27 09:25:12 +00:00
|
|
|
@@ -77,6 +77,7 @@ static struct addr_range percpu_range =
|
2022-10-18 20:26:34 +00:00
|
|
|
static struct sym_entry **table;
|
|
|
|
static unsigned int table_size, table_cnt;
|
|
|
|
static int all_symbols;
|
|
|
|
+static int uncompressed;
|
|
|
|
static int absolute_percpu;
|
|
|
|
static int base_relative;
|
2023-07-27 09:25:12 +00:00
|
|
|
static int lto_clang;
|
2023-10-25 18:36:20 +00:00
|
|
|
@@ -608,6 +609,9 @@ static void write_src(void)
|
|
|
|
(unsigned char)(table[i]->seq >> 0));
|
2023-07-27 09:25:12 +00:00
|
|
|
printf("\n");
|
2022-10-18 20:26:34 +00:00
|
|
|
|
|
|
|
+ if (uncompressed)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
output_label("kallsyms_token_table");
|
|
|
|
off = 0;
|
|
|
|
for (i = 0; i < 256; i++) {
|
2023-10-25 18:36:20 +00:00
|
|
|
@@ -659,6 +663,9 @@ static unsigned char *find_token(unsigne
|
2022-10-18 20:26:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
+ if (uncompressed)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
for (i = 0; i < len - 1; i++) {
|
|
|
|
if (str[i] == token[0] && str[i+1] == token[1])
|
|
|
|
return &str[i];
|
2023-10-25 18:36:20 +00:00
|
|
|
@@ -731,6 +738,9 @@ static void optimize_result(void)
|
2022-10-18 20:26:34 +00:00
|
|
|
{
|
|
|
|
int i, best;
|
|
|
|
|
|
|
|
+ if (uncompressed)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
/* using the '\0' symbol last allows compress_symbols to use standard
|
|
|
|
* fast string functions */
|
|
|
|
for (i = 255; i >= 0; i--) {
|
2023-10-25 18:36:20 +00:00
|
|
|
@@ -892,6 +902,7 @@ int main(int argc, char **argv)
|
2022-10-18 21:24:43 +00:00
|
|
|
{"absolute-percpu", no_argument, &absolute_percpu, 1},
|
|
|
|
{"base-relative", no_argument, &base_relative, 1},
|
2023-07-27 09:25:12 +00:00
|
|
|
{"lto-clang", no_argument, <o_clang, 1},
|
2022-10-18 21:24:43 +00:00
|
|
|
+ {"uncompressed", no_argument, &uncompressed, 1},
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
2022-10-18 20:26:34 +00:00
|
|
|
--- a/scripts/link-vmlinux.sh
|
|
|
|
+++ b/scripts/link-vmlinux.sh
|
2024-02-23 20:40:12 +00:00
|
|
|
@@ -165,6 +165,10 @@ kallsyms()
|
2023-07-27 09:25:12 +00:00
|
|
|
kallsymopt="${kallsymopt} --lto-clang"
|
2022-10-18 20:26:34 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-18 21:24:43 +00:00
|
|
|
+ if is_enabled CONFIG_KALLSYMS_UNCOMPRESSED; then
|
2022-10-18 20:26:34 +00:00
|
|
|
+ kallsymopt="${kallsymopt} --uncompressed"
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
info KSYMS ${2}
|
2023-05-22 16:07:49 +00:00
|
|
|
scripts/kallsyms ${kallsymopt} ${1} > ${2}
|
2022-10-18 20:26:34 +00:00
|
|
|
}
|