From patchwork Tue Jun 3 05:01:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle McMartin X-Patchwork-Id: 31316 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DCE16203C2 for ; Tue, 3 Jun 2014 05:02:24 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id y20sf32423030ier.11 for ; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-subscribe:list-archive:list-post:list-help :sender:delivered-to:date:from:to:subject:message-id:mime-version :in-reply-to:user-agent:x-original-sender :x-original-authentication-results:content-type:content-disposition; bh=6urOYVCiwKdlg5KDNzlBqqrW/ZQVhaYzZ87PUZo/q9M=; b=i3ZJKvsnE4Pm+6gpjtw53l9YigsfCAherPtZ45rJwE9cBNHjh0bCLipnv9wjLYZHNw 1omBV+tQdrQBDZCTKUPTKdpJAhBdAHlQA56J7ycX/DdrcHECPwFXIrqmyjoGSdoDhbDC +IUHgNzazjzWmmOA6SqCstm3feFjtXn3EFK2j8aY0qWc2GHC/CfA1m9GvAeWNdBnyv4k 9eDXHheigiULX2yThlZvKqL0qtlooPmn+Xe9G/kDjfi8Feqn88RBXqH8BnrTx0ZeRbC+ n79mPQLDITZYwY3iqjLw+ikKgO2UokuaYHvaaV1ASPUTB1FdPS8geQpdnHBacz6T4Czb y8kg== X-Gm-Message-State: ALoCoQno389EqtOyqfgOaFfwI/xQh6fmtF3ycQzrYrm0cuaO0RLGQSIwwIwD+H8qWcCUHVrWNGXa X-Received: by 10.43.94.71 with SMTP id bx7mr14926753icc.2.1401771743792; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.135 with SMTP id e7ls2344395qga.70.gmail; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) X-Received: by 10.53.12.229 with SMTP id et5mr8245608vdd.32.1401771743698; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) Received: from mail-ve0-x236.google.com (mail-ve0-x236.google.com [2607:f8b0:400c:c01::236]) by mx.google.com with ESMTPS id fj8si9303687vdc.35.2014.06.02.22.02.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 22:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::236 as permitted sender) client-ip=2607:f8b0:400c:c01::236; Received: by mail-ve0-f182.google.com with SMTP id sa20so6496185veb.27 for ; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) X-Received: by 10.52.243.225 with SMTP id xb1mr6429273vdc.36.1401771743606; Mon, 02 Jun 2014 22:02:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp149084vcb; Mon, 2 Jun 2014 22:02:23 -0700 (PDT) X-Received: by 10.66.183.11 with SMTP id ei11mr46409923pac.116.1401771742835; Mon, 02 Jun 2014 22:02:22 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id yr5si18793074pab.84.2014.06.02.22.02.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 22:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-112985-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9188 invoked by alias); 3 Jun 2014 05:02:16 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Subscribe: List-Archive: List-Post: , List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 9167 invoked by uid 89); 3 Jun 2014 05:02:14 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jun 2014 05:01:57 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5351ueT020644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 3 Jun 2014 01:01:56 -0400 Received: from redacted.bos.redhat.com ([10.18.17.143]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5351sY3002323 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO) for ; Tue, 3 Jun 2014 01:01:55 -0400 Date: Tue, 3 Jun 2014 01:01:54 -0400 From: Kyle McMartin To: gdb-patches@sourceware.org Subject: [PATCH 1/2] aarch64: extend decode_adrp to decode immediate offset Message-ID: <20140603050153.GB15355@redacted.bos.redhat.com> MIME-Version: 1.0 In-Reply-To: <20140603050011.GA15355@redacted.bos.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-Original-Sender: kmcmarti@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::236 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Content-Disposition: inline This is needed in order to figure out what an ADRP instruction is attempting to calculate the address of, for use by a further functionality. gdb/ 2014-06-03 Kyle McMartin * aarch64-tdep.c (decode_adrp): Generalise function to handle ADR as well as ADRP, and decode the offset. (aarch64_analyze_prologue): Discard unneeded arguments to decode_adrp. --- gdb/aarch64-tdep.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 4abe36e..9550f42 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -255,7 +255,7 @@ decode_add_sub_imm (CORE_ADDR addr, uint32_t insn, unsigned *rd, unsigned *rn, return 0; } -/* Decode an opcode if it represents an ADRP instruction. +/* Decode an opcode if it represents an ADRP/ADR instruction. ADDR specifies the address of the opcode. INSN specifies the opcode to test. @@ -264,16 +264,28 @@ decode_add_sub_imm (CORE_ADDR addr, uint32_t insn, unsigned *rd, unsigned *rn, Return 1 if the opcodes matches and is decoded, otherwise 0. */ static int -decode_adrp (CORE_ADDR addr, uint32_t insn, unsigned *rd) +decode_adrp (CORE_ADDR addr, uint32_t insn, int *page, unsigned *rd, + int64_t *imm) { - if (decode_masked_match (insn, 0x9f000000, 0x90000000)) + if (decode_masked_match (insn, 0x1f000000, 0x10000000)) { *rd = (insn >> 0) & 0x1f; + *imm = (extract_signed_bitfield (insn, 19, 5) << 2) + | ((insn >> 29) & 0x3); + *page = 0; + + if (insn & 0x80000000) + { + *page = 1; + *imm <<= 12; + } if (aarch64_debug) fprintf_unfiltered (gdb_stdlog, - "decode: 0x%s 0x%x adrp x%u, #?\n", - core_addr_to_string_nz (addr), insn, *rd); + "decode: 0x%s 0x%x %s x%u, #0x%llx\n", + core_addr_to_string_nz (addr), insn, + *page ? "adrp" : "adr", *rd, + (unsigned long long)*imm); return 1; } return 0; @@ -681,8 +693,10 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, unsigned rt2; int op_is_sub; int32_t imm; + int64_t imm64; unsigned cond; int is64; + int page; unsigned is_link; unsigned op; unsigned bit; @@ -692,7 +706,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, if (decode_add_sub_imm (start, insn, &rd, &rn, &imm)) regs[rd] = pv_add_constant (regs[rn], imm); - else if (decode_adrp (start, insn, &rd)) + else if (decode_adrp (start, insn, &page, &rd, &imm64)) regs[rd] = pv_unknown (); else if (decode_b (start, insn, &is_link, &offset)) {