This is the mail archive of the gdb-patches@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]

[PATCH] Fix amd64_relocate_instruction/i386_relocate_instruction host-endianess-assumption bug.


I've noticed by inspection that amd64_relocate_instruction and
i386_relocate_instruction have an host/target-endianess-assumption
bug.  This patch fixes it.

Tested on AMD64 Fedora 17, and applied as obvious.

gdb/
2012-10-26  Pedro Alves  <palves@redhat.com>

	* amd64-tdep.c (amd64_relocate_instruction): Use
	store_unsigned_integer instead of memcpy.
	* i386-tdep.c (i386_relocate_instruction): Ditto.
---
 gdb/amd64-tdep.c |    2 +-
 gdb/i386-tdep.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index a4172fc..2edaecf 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -1631,7 +1631,7 @@ amd64_relocate_instruction (struct gdbarch *gdbarch,
       /* Where "ret" in the original code will return to.  */
       ret_addr = oldloc + insn_length;
       push_buf[0] = 0x68; /* pushq $...  */
-      memcpy (&push_buf[1], &ret_addr, 4);
+      store_unsigned_integer (&push_buf[1], 4, byte_order, ret_addr);
       /* Push the push.  */
       append_insns (to, 5, push_buf);
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 2768dbc..df29b71 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -750,7 +750,7 @@ i386_relocate_instruction (struct gdbarch *gdbarch,
       /* Where "ret" in the original code will return to.  */
       ret_addr = oldloc + insn_length;
       push_buf[0] = 0x68; /* pushq $...  */
-      memcpy (&push_buf[1], &ret_addr, 4);
+      store_unsigned_integer (&push_buf[1], 4, byte_order, ret_addr);
       /* Push the push.  */
       append_insns (to, 5, push_buf);
 


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