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]

[rfa/gdbserver] Fix ppc64 bi-arch TLS bug


Hello,

this fixes another bug in ppc64 bi-arch gdbserver support: the
ppc_collect_ptrace_register did not zero out the register buffer
(in the case of a 4-byte inferior register on a 64-bit host).

This doesn't matter for the main user of this function
(usr_store_inferior_registers in linux-low.c) which always
zeros the buffer itself before passing it in.

However, there is a second caller, ps_lgetregs in proc-service.c
(via the ppc_fill_gregset function) which does *not* zero the
buffer.  This could cause TLS access to fail in some instances
of 64->32 bit bi-arch debugging.

Fixed by simply always clearing the register buffer.

Tested on powerpc64-linux (-m64/-m32) and powerpc-linux using
local gdbserver.

OK for mainline?

Bye,
Ulrich


ChangeLog:

	* linux-ppc-low.c (ppc_collect_ptrace_register): Clear buffer.

diff -urNp gdb-orig/gdb/gdbserver/linux-ppc-low.c gdb-head/gdb/gdbserver/linux-ppc-low.c
--- gdb-orig/gdb/gdbserver/linux-ppc-low.c	2008-05-11 23:03:06.000000000 +0200
+++ gdb-head/gdb/gdbserver/linux-ppc-low.c	2008-05-28 19:24:33.372182584 +0200
@@ -149,6 +149,9 @@ static void
 ppc_collect_ptrace_register (int regno, char *buf)
 {
   int size = register_size (regno);
+
+  memset (buf, 0, sizeof (long));
+
   if (size < sizeof (long))
     collect_register (regno, buf + sizeof (long) - size);
   else
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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