Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/kallsyms: filter symbols not in kernel address space

This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.

For example, on ARM there are some symbols which may be
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, this patch fixes the
problem (introduced b9b32bf70f2fb710b07c94e13afbc729afe221da)

Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: stable@vger.kernel.org

authored by

Ming Lei and committed by
Rusty Russell
f6537f2f 12aee278

+13 -1
+11 -1
scripts/kallsyms.c
··· 55 static unsigned int table_size, table_cnt; 56 static int all_symbols = 0; 57 static char symbol_prefix_char = '\0'; 58 59 int token_profit[0x10000]; 60 ··· 66 67 static void usage(void) 68 { 69 - fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n"); 70 exit(1); 71 } 72 ··· 197 NULL }; 198 int i; 199 int offset = 1; 200 201 /* skip prefix char */ 202 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) ··· 653 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) 654 p++; 655 symbol_prefix_char = *p; 656 } else 657 usage(); 658 }
··· 55 static unsigned int table_size, table_cnt; 56 static int all_symbols = 0; 57 static char symbol_prefix_char = '\0'; 58 + static unsigned long long kernel_start_addr = 0; 59 60 int token_profit[0x10000]; 61 ··· 65 66 static void usage(void) 67 { 68 + fprintf(stderr, "Usage: kallsyms [--all-symbols] " 69 + "[--symbol-prefix=<prefix char>] " 70 + "[--page-offset=<CONFIG_PAGE_OFFSET>] " 71 + "< in.map > out.S\n"); 72 exit(1); 73 } 74 ··· 193 NULL }; 194 int i; 195 int offset = 1; 196 + 197 + if (s->addr < kernel_start_addr) 198 + return 0; 199 200 /* skip prefix char */ 201 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) ··· 646 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) 647 p++; 648 symbol_prefix_char = *p; 649 + } else if (strncmp(argv[i], "--page-offset=", 14) == 0) { 650 + const char *p = &argv[i][14]; 651 + kernel_start_addr = strtoull(p, NULL, 16); 652 } else 653 usage(); 654 }