This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb/gdb-7.12-branch] x32: Avoid unsigned long when installing fast tracepoint jump pads


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=53e8498437380263d5321bf841c6de526e676347

commit 53e8498437380263d5321bf841c6de526e676347
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Aug 23 23:17:12 2016 +0100

    x32: Avoid unsigned long when installing fast tracepoint jump pads
    
    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:
    2016-08-23  Pedro Alves  <palves@redhat.com>
    
    	* linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Fix
    	comment.  Use memcpy instead of casting through unsigned long.

Diff:
---
 gdb/gdbserver/ChangeLog       | 5 +++++
 gdb/gdbserver/linux-x86-low.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index bed2719..b09f802 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
 2016-08-23  Pedro Alves  <palves@redhat.com>
 
+	* linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Fix
+	comment.  Use memcpy instead of casting through unsigned long.
+
+2016-08-23  Pedro Alves  <palves@redhat.com>
+
 	* linux-amd64-ipa.c (alloc_jump_pad_buffer) [__ILP32__]: Try
 	allocating around 0x80000000.
 
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 <addr>,%rdi */
+  buf[i++] = 0x48; /* movabs <addr>,%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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]