From: Pedro Alves Date: Fri, 19 Aug 2016 11:07:45 +0000 (+0100) Subject: x32: Avoid unsigned long when installing fast tracepoint jump pads X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8ef42eed100c2439e600e846caa7437da93ac17;p=binutils-gdb.git 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-19 Pedro Alves * linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Fix comment. Use memcpy instead of casting through unsigned long. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index ed5364850c5..f59d389db6e 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2016-08-19 Pedro Alves + + * linux-x86-low.c (amd64_install_fast_tracepoint_jump_pad): Fix + comment. Use memcpy instead of casting through unsigned long. + 2016-08-19 Pedro Alves * linux-amd64-ipa.c (alloc_jump_pad_buffer) [__ILP32__]: Try diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index d6b67c1b885..1ba98ba4e07 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);