From patchwork Mon Oct 28 15:48:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 3103161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D59D29F6F7 for ; Mon, 28 Oct 2013 15:50:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35D4B20214 for ; Mon, 28 Oct 2013 15:49:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F22B420213 for ; Mon, 28 Oct 2013 15:49:55 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vap4i-0002I3-Og; Mon, 28 Oct 2013 15:49:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vap4g-0000eJ-7X; Mon, 28 Oct 2013 15:49:50 +0000 Received: from mail-pd0-x233.google.com ([2607:f8b0:400e:c02::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vap4c-0000d1-G2 for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2013 15:49:47 +0000 Received: by mail-pd0-f179.google.com with SMTP id y10so7297044pdj.10 for ; Mon, 28 Oct 2013 08:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=4sZJ7vbFK/bhS0tEvGG6NoG9E2LLndYLdN6YBJ+vcXA=; b=dOgqbpFFoz+fPsMkz+PL/nQ+cuVqd0kNAKPhAGUNq3LoAY8fWDR6Vc0+c4e4X1Unee 9iaqKbh0l5C9nv0Fwqpp4KH5JGL4FqlJ2YA8YvvvEMw1RblQ+4TU9KPfAGUGlczb3TTM Q8EF4TOMPNWGE/CA4aKbtAP6VISm3BHT83mW8PPk869TiLzD6gNsVMSIzDjqgt0660ze eqLOv+K6rOJUkoVTJHZdfLayC9gcaDi6wRphJ5i2lvrUKS/Q0ORNdwql0gw4jEi3bist IZNhVKjeUxBpFxzRVruzkMgA/Y1uIHgmoXvCnOy0RZtseelWLGVwHvvuzj2oci6FbtWj c6mQ== X-Received: by 10.66.27.4 with SMTP id p4mr26434898pag.25.1382975364936; Mon, 28 Oct 2013 08:49:24 -0700 (PDT) Received: from localhost ([14.155.87.20]) by mx.google.com with ESMTPSA id gg10sm29327201pbc.46.2013.10.28.08.49.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 28 Oct 2013 08:49:24 -0700 (PDT) From: Ming Lei To: Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] scripts/kallsyms: filter symbols not in kernel address space Date: Mon, 28 Oct 2013 23:48:59 +0800 Message-Id: <1382975339-25831-1-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131028_114946_687016_F162AFBE X-CRM114-Status: GOOD ( 17.01 ) X-Spam-Score: -2.0 (--) Cc: Michal Marek , Ming Lei , Rusty Russell , Russell King , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 are linked in relocatable code section, then perf can't parse symbols any more from /proc/kallsyms, and this patch fixes the problem. Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Cc: Michal Marek Acked-by: Rusty Russell Signed-off-by: Ming Lei --- scripts/kallsyms.c | 12 +++++++++++- scripts/link-vmlinux.sh | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 487ac6f..9a11f9f 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -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=] < in.map > out.S\n"); + fprintf(stderr, "Usage: kallsyms [--all-symbols] " + "[--symbol-prefix=] " + "[--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(); } diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 0149949..32b10f5 100644 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -82,6 +82,8 @@ kallsyms() kallsymopt="${kallsymopt} --all-symbols" fi + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" + local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"