From patchwork Thu Jul 28 01:01:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 14063 Received: (qmail 107969 invoked by alias); 28 Jul 2016 01:01:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk 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 107864 invoked by uid 89); 28 Jul 2016 01:01:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 28 Jul 2016 01:01:31 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0466580F72 for ; Thu, 28 Jul 2016 01:01:30 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6S11Qsi027476 for ; Wed, 27 Jul 2016 21:01:29 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 3/6] x32: Avoid unsigned long when installing fast tracepoint jump pads Date: Thu, 28 Jul 2016 02:01:22 +0100 Message-Id: <1469667685-10848-4-git-send-email-palves@redhat.com> In-Reply-To: <1469667685-10848-1-git-send-email-palves@redhat.com> References: <1469667685-10848-1-git-send-email-palves@redhat.com> We're casting through unsigned long to write a 64-bit immediate operand of movabs (the comment said movl, but that was incorrect). The problem is that unsigned long is 32-bit on x32, so we were writing fewer bytes than necessary. Fix this by using an 8 byte memcpy like in other similar places in the function. gdb/gdbserver/ChangeLog: yyyy-mm-dd Pedro Alves * linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Fix comment. Use memcpy instead of casting through unsigned long. --- gdb/gdbserver/linux-x86-low.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index d6b67c1..1ba98ba 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -1092,10 +1092,10 @@ amd64_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr, buf[i++] = 0x41; buf[i++] = 0x51; /* push %r9 */ buf[i++] = 0x41; buf[i++] = 0x50; /* push %r8 */ buf[i++] = 0x9c; /* pushfq */ - buf[i++] = 0x48; /* movl ,%rdi */ + buf[i++] = 0x48; /* movabs ,%rdi */ buf[i++] = 0xbf; - *((unsigned long *)(buf + i)) = (unsigned long) tpaddr; - i += sizeof (unsigned long); + memcpy (buf + i, &tpaddr, 8); + i += 8; buf[i++] = 0x57; /* push %rdi */ append_insns (&buildaddr, i, buf);