aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kallsyms.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2013-11-01 18:41:33 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-11-01 18:43:02 -0400
commitf6537f2f0eba4eba3354e48dbe3047db6d8b6254 (patch)
tree20541922629260f7e48eaacc9c5e590d33a461c4 /scripts/kallsyms.c
parent12aee278b50c4a94a93fa0b4d201ae35d792c696 (diff)
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
Diffstat (limited to 'scripts/kallsyms.c')
-rw-r--r--scripts/kallsyms.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 487ac6f37ca2..9a11f9f799f4 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -55,6 +55,7 @@ static struct sym_entry *table;
55static unsigned int table_size, table_cnt; 55static unsigned int table_size, table_cnt;
56static int all_symbols = 0; 56static int all_symbols = 0;
57static char symbol_prefix_char = '\0'; 57static char symbol_prefix_char = '\0';
58static unsigned long long kernel_start_addr = 0;
58 59
59int token_profit[0x10000]; 60int token_profit[0x10000];
60 61
@@ -65,7 +66,10 @@ unsigned char best_table_len[256];
65 66
66static void usage(void) 67static void usage(void)
67{ 68{
68 fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n"); 69 fprintf(stderr, "Usage: kallsyms [--all-symbols] "
70 "[--symbol-prefix=<prefix char>] "
71 "[--page-offset=<CONFIG_PAGE_OFFSET>] "
72 "< in.map > out.S\n");
69 exit(1); 73 exit(1);
70} 74}
71 75
@@ -194,6 +198,9 @@ static int symbol_valid(struct sym_entry *s)
194 int i; 198 int i;
195 int offset = 1; 199 int offset = 1;
196 200
201 if (s->addr < kernel_start_addr)
202 return 0;
203
197 /* skip prefix char */ 204 /* skip prefix char */
198 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) 205 if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
199 offset++; 206 offset++;
@@ -646,6 +653,9 @@ int main(int argc, char **argv)
646 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) 653 if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
647 p++; 654 p++;
648 symbol_prefix_char = *p; 655 symbol_prefix_char = *p;
656 } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
657 const char *p = &argv[i][14];
658 kernel_start_addr = strtoull(p, NULL, 16);
649 } else 659 } else
650 usage(); 660 usage();
651 } 661 }