From patchwork Thu Sep 28 18:01:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 9976589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4E826034B for ; Thu, 28 Sep 2017 18:01:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C476B296EF for ; Thu, 28 Sep 2017 18:01:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C199A296FA; Thu, 28 Sep 2017 18:01:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E731296EA for ; Thu, 28 Sep 2017 18:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TUNciMJlWa1x/8Fa6uxb22iJy9ZOexzdMQsltKyVzRk=; b=UmD/f6F4PsibaE bwt6cbXwpyeVpWccfkLzt5if7Y+yQmdkMVesXT6prCoyE8r4//Pc6Gwjo44At4e42BHNkCpZv1J7v YdeXfsXAnC6qe4GdkJLdCCQx5wiZo0BQNHDzmdPHnu3MdMGyUk4/1MmIJoZSmucczIp/zobui3/WO 6J0R8yT2avURxR6xQ1Sc3Ls9Crclmp3e/5bj0XGqmJxd4VRAZmuK4BGWiJNl91I08Dx4Iu7SAabNj Rto7j48fmZs4yCTSYo2ApL8c3hZchlF3rKLhryCGgfU2AacnlwGBrePRkJPrlWAyDTsueq8tSke9F ixVEpD1f+J9ubmTwutBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dxd8A-0001tC-U9; Thu, 28 Sep 2017 18:01:50 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dxd81-0001lM-QN for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2017 18:01:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F1DE51529; Thu, 28 Sep 2017 11:01:20 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C34573F53D; Thu, 28 Sep 2017 11:01:20 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 773E41AE3036; Thu, 28 Sep 2017 19:01:35 +0100 (BST) Date: Thu, 28 Sep 2017 19:01:35 +0100 From: Will Deacon To: Dave Martin Subject: Re: [PATCH] scripts/decodecode: Fix decoding for AArch64 (arm64) instructions Message-ID: <20170928180135.GH9892@arm.com> References: <1506596147-23630-1-git-send-email-will.deacon@arm.com> <20170928124206.GA3611@e103592.cambridge.arm.com> <20170928141447.GA27788@arm.com> <20170928143704.GC3611@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170928143704.GC3611@e103592.cambridge.arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170928_110141_865210_E1D4191F X-CRM114-Status: GOOD ( 20.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mmarek@suse.cz, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Sep 28, 2017 at 03:37:04PM +0100, Dave Martin wrote: > On Thu, Sep 28, 2017 at 03:14:47PM +0100, Will Deacon wrote: > > On Thu, Sep 28, 2017 at 01:42:31PM +0100, Dave Martin wrote: > > > On Thu, Sep 28, 2017 at 11:55:47AM +0100, Will Deacon wrote: > > > > There are a couple of problems with the decodecode script and arm64: > > > > > > > > 1. AArch64 objdump refuses to disassemble .4byte directives as instructions, > > > > insisting that they are data values and displaying them as: > > > > > > > > a94153f3 .word 0xa94153f3 <-- trapping instruction > > > > > > > > This is resolved by using the .inst directive instead. > > > > > > > > 2. Disassembly of branch instructions attempts to provide the target as > > > > an offset from a symbol, e.g.: > > > > > > > > 0: 34000082 cbz w2, 10 <.text+0x10> > > > > > > > > however this falls foul of the grep -v, which matches lines containing > > > > ".text" and ends up removing all branch instructions from the dump. > > > > > > Any idea why this doesn't affect other arches too ... or does it? > > > > I'm not sure, although I don't know how .inst works for architectures > > with variable-length instructions and I *guess* the disassembly is less > > fussy about data vs text for those targets. > > I rather meant the target disassembly for relative branches in the > absence of labels. > > Anyway, I think this is at least harmless to other arches, and possibly > helpful to them (if they disassemble those branch targets in the same > sort of way). Ah, I see what you mean. Something like the fixup below on top. Will --->8 diff --git a/scripts/decodecode b/scripts/decodecode index 67214ec5b2cb..f1ec57c3cbf7 100755 --- a/scripts/decodecode +++ b/scripts/decodecode @@ -49,21 +49,14 @@ esac disas() { ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s > /dev/null 2>&1 + ${CROSS_COMPILE}strip $1.o - if [ "$ARCH" = "arm" ]; then - if [ $width -eq 2 ]; then - OBJDUMPFLAGS="-M force-thumb" - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm" -a $width -eq 2 ]; then + OBJDUMPFLAGS="-M force-thumb" fi - if [ "$ARCH" = "arm64" ]; then - if [ $width -eq 4 ]; then - type=inst - fi - - ${CROSS_COMPILE}strip $1.o + if [ "$ARCH" = "arm64" -a $width -eq 4 ]; then + type=inst fi ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \