From patchwork Wed Jan 14 18:38:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Kamensky X-Patchwork-Id: 5634351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF422C058D for ; Wed, 14 Jan 2015 18:42:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC92E2017E for ; Wed, 14 Jan 2015 18:42:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA40520160 for ; Wed, 14 Jan 2015 18:42:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBSqP-0003Ak-3i; Wed, 14 Jan 2015 18:39:05 +0000 Received: from mail-qg0-f47.google.com ([209.85.192.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBSqK-00034s-TW for linux-arm-kernel@lists.infradead.org; Wed, 14 Jan 2015 18:39:02 +0000 Received: by mail-qg0-f47.google.com with SMTP id q108so8323025qgd.6 for ; Wed, 14 Jan 2015 10:38:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=8FdVC+CusLLDNtlwBatemOY5zfD3Rm7y6OBYWoK9GqA=; b=IWW2s72LLx1R3N8azKihw9iKdptB28y2tVurKV0RnT0mxwvvLW46C4dsZIt9oB/NwU SjlRy1NAs8mjjx+tdEWQTFdeMTb/7U42oGOwMViw2f7ie/UFHLomQSgPXws7+dmuyShu 7DeagKm1lw8OQRIfyc+U3ezHC58248NdkOLeXD+EZpOTJABBMJcHLjo3rEOO3k8eHA1z rE+6cMmQFp/1e13VYKXacr54C2YhO2HhoiZZaRZTPYrY9QtV+w3MDJ84oTJfH1dMSOZo xebaad+8QJz7C23Up7JzIhL0OhsTgn0EitwkL2zbCe0p3/Fw7dFBWz5NdguwYSY8PxZp GDXA== X-Gm-Message-State: ALoCoQkniNe3wGcrwN2MQJkaHfKIn28wTdgfiE8pI8RG9kdcUS3XO9AU4NRWneoEO9y6VL4UQGDS MIME-Version: 1.0 X-Received: by 10.140.108.74 with SMTP id i68mr8830661qgf.35.1421260718729; Wed, 14 Jan 2015 10:38:38 -0800 (PST) Received: by 10.229.245.202 with HTTP; Wed, 14 Jan 2015 10:38:38 -0800 (PST) In-Reply-To: <20150114112210.GF4050@arm.com> References: <1421168344-5363-1-git-send-email-victor.kamensky@linaro.org> <20150114112210.GF4050@arm.com> Date: Wed, 14 Jan 2015 10:38:38 -0800 Message-ID: Subject: Re: [PATCH 1/2] perf symbols: Ignore mapping symbols on aarch64 From: Victor Kamensky To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150114_103901_026362_E72831C9 X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -0.7 (/) Cc: Avi Kivity , Peter Zijlstra , Adrian Hunter , Arnaldo Carvalho de Melo , "linux-kernel@vger.kernel.org" , Ingo Molnar , Paul Mackerras , Anton Blanchard , David Ahern , Masami Hiramatsu , Namhyung Kim , Jiri Olsa , Dave P Martin , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 On 14 January 2015 at 03:22, Will Deacon wrote: > On Tue, Jan 13, 2015 at 04:59:03PM +0000, Victor Kamensky wrote: >> Aarch64 ELF files use mapping symbols with special names $x, $d >> to identify regions of Aarch64 code (see Aarch64 ELF ABI - "ARM >> IHI 0056B", section "4.5.4 Mapping symbols"). >> >> The patch filters out these symbols at load time, similar to >> "696b97a perf symbols: Ignore mapping symbols on ARM" changes >> done for ARM before V8. >> >> Signed-off-by: Victor Kamensky >> Cc: Peter Zijlstra >> Cc: Paul Mackerras >> Cc: Ingo Molnar >> Cc: Arnaldo Carvalho de Melo >> Cc: Adrian Hunter >> Cc: Jiri Olsa >> Cc: Namhyung Kim >> Cc: Avi Kivity >> Cc: Masami Hiramatsu >> Cc: Anton Blanchard >> Cc: David Ahern >> Cc: Will Deacon >> Cc: Dave Martin >> --- >> tools/perf/util/symbol-elf.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c >> index 06fcd1b..1e188dd 100644 >> --- a/tools/perf/util/symbol-elf.c >> +++ b/tools/perf/util/symbol-elf.c >> @@ -862,6 +862,14 @@ int dso__load_sym(struct dso *dso, struct map *map, >> !strcmp(elf_name, "$t")) >> continue; >> } >> + /* Reject Aarch64 ELF "mapping symbols": these aren't unique and >> + * don't identify functions, so will confuse the profile >> + * output: */ >> + if (ehdr.e_machine == EM_AARCH64) { >> + if (!strcmp(elf_name, "$x") || >> + !strcmp(elf_name, "$d")) >> + continue; >> + } > > Do we need to skip $x.* and $d.* too? I doubt GCC generates them, but they > are permitted by the ELF ABI. Fair enough. But I think it would need to be done for both EM_ARM and EM_AARCH64. My above patch follows EM_ARM current case. Also it seems that it would be quite rare case, as ABI suggests symbols with dot notation should be used in manual asm where assembler does not support multiple definitions of the same symbol. Will something like the following suffice? I can add that as separate follow up patch in this small series. Tested with explicit "$x.func1" symbol introduced in manual asm. From fed6caab410ddcaf487ff23a3908eca129e50b89 Mon Sep 17 00:00:00 2001 From: Victor Kamensky Date: Wed, 14 Jan 2015 07:42:41 -0800 Subject: [PATCH 3/3] perf symbols: improve abi compliance in arm mapping symbols handling Both Arm and Aarch64 ELF ABI allow mapping symbols be in from either "$d" or "$d.". But current code that handles mapping symbols only deals with the first, dollar character and a single letter, case. The patch adds handling of the second case with period followed by any characters. Suggested-by: Will Deacon Signed-off-by: Victor Kamensky --- tools/perf/util/symbol-elf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 1e188dd..ae92c27 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -859,7 +859,10 @@ int dso__load_sym(struct dso *dso, struct map *map, if (ehdr.e_machine == EM_ARM) { if (!strcmp(elf_name, "$a") || !strcmp(elf_name, "$d") || - !strcmp(elf_name, "$t")) + !strcmp(elf_name, "$t") || + !strncmp(elf_name, "$a.", 3) || + !strncmp(elf_name, "$d.", 3) || + !strncmp(elf_name, "$t.", 3)) continue; } /* Reject Aarch64 ELF "mapping symbols": these aren't unique and @@ -867,7 +870,9 @@ int dso__load_sym(struct dso *dso, struct map *map, * output: */ if (ehdr.e_machine == EM_AARCH64) { if (!strcmp(elf_name, "$x") || - !strcmp(elf_name, "$d")) + !strcmp(elf_name, "$d") || + !strncmp(elf_name, "$x.", 3) || + !strncmp(elf_name, "$d.", 3)) continue; }