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) Change-Id: I3d6321b7d87727c7c2802b3924f2e89a28e4b9ca 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 Git-commit: f6537f2f0eba4eba3354e48dbe3047db6d8b6254 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git CRs-fixed: 583755 [nleeder@codeaurora.org: move flag to Makefile because original file scripts/link-vmlinux.sh does not exist in 3.4] Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
This commit is contained in:
parent
904c14d402
commit
4fa4c84d40
1
Makefile
1
Makefile
|
@ -864,6 +864,7 @@ endef
|
|||
# Generate .S file with all kernel symbols
|
||||
quiet_cmd_kallsyms = KSYM $@
|
||||
cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
|
||||
--page-offset=$(CONFIG_PAGE_OFFSET) \
|
||||
$(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
|
||||
|
||||
.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
|
||||
|
|
|
@ -55,6 +55,7 @@ static struct sym_entry *table;
|
|||
static unsigned int table_size, table_cnt;
|
||||
static int all_symbols = 0;
|
||||
static char symbol_prefix_char = '\0';
|
||||
static unsigned long long kernel_start_addr = 0;
|
||||
|
||||
int token_profit[0x10000];
|
||||
|
||||
|
@ -65,7 +66,10 @@ unsigned char best_table_len[256];
|
|||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--symbol-prefix=<prefix char>] < in.map > out.S\n");
|
||||
fprintf(stderr, "Usage: kallsyms [--all-symbols] "
|
||||
"[--symbol-prefix=<prefix char>] "
|
||||
"[--page-offset=<CONFIG_PAGE_OFFSET>] "
|
||||
"< in.map > out.S\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -194,6 +198,9 @@ static int symbol_valid(struct sym_entry *s)
|
|||
int i;
|
||||
int offset = 1;
|
||||
|
||||
if (s->addr < kernel_start_addr)
|
||||
return 0;
|
||||
|
||||
/* skip prefix char */
|
||||
if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char)
|
||||
offset++;
|
||||
|
@ -646,6 +653,9 @@ int main(int argc, char **argv)
|
|||
if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
|
||||
p++;
|
||||
symbol_prefix_char = *p;
|
||||
} else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
|
||||
const char *p = &argv[i][14];
|
||||
kernel_start_addr = strtoull(p, NULL, 16);
|
||||
} else
|
||||
usage();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue