aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2009-07-13 20:16:48 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2009-07-13 20:16:48 +0000
commit8f3139231259ed3202513d7a83d0a25cb051a62a (patch)
treeaad3fe502be9bbfa3e05b21b1e79911dfd3ffc2d /gdb/linux-nat.c
parent4662c76e915914dd6fe77a4878fa9a7c8385b7d1 (diff)
downloadgdb-8f3139231259ed3202513d7a83d0a25cb051a62a.zip
gdb-8f3139231259ed3202513d7a83d0a25cb051a62a.tar.gz
gdb-8f3139231259ed3202513d7a83d0a25cb051a62a.tar.bz2
gdb/
Fix memory access from signed 32bit inferior registers on 64bit GDB. * linux-nat.c (linux_xfer_partial <TARGET_OBJECT_MEMORY>): New variable addr_bit. Mask OFFSET by the ADDR_BIT width. gdb/testsuite/ * gdb.arch/amd64-i386-address.exp, gdb.arch/amd64-i386-address.S: New.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index f8d7a5c..d91c6be 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4260,6 +4260,20 @@ linux_xfer_partial (struct target_ops *ops, enum target_object object,
return linux_nat_xfer_osdata (ops, object, annex, readbuf, writebuf,
offset, len);
+ /* GDB calculates all the addresses in possibly larget width of the address.
+ Address width needs to be masked before its final use - either by
+ linux_proc_xfer_partial or inf_ptrace_xfer_partial.
+
+ Compare ADDR_BIT first to avoid a compiler warning on shift overflow. */
+
+ if (object == TARGET_OBJECT_MEMORY)
+ {
+ int addr_bit = gdbarch_addr_bit (target_gdbarch);
+
+ if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
+ offset &= ((ULONGEST) 1 << addr_bit) - 1;
+ }
+
xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf,
offset, len);
if (xfer != 0)