components/gdb/patches/gdb.auxv.c.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Wed, 29 Aug 2012 11:05:56 -0700
changeset 957 255465c5756f
parent 243 34b34302cac9
permissions -rw-r--r--
Close of build 04.

--- gdb-6.8.orig/gdb/auxv.c	Wed Jan 16 08:27:37 2008
+++ gdb-6.8-64/gdb/auxv.c	Tue Aug 31 14:41:16 2010
@@ -82,7 +82,15 @@
 target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 		   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  const int sizeof_auxv_field = TYPE_LENGTH (builtin_type_void_data_ptr);
+ 
+  /*
+   * Solaris pads out the auxv for 32 bit process to 64 bits when
+   * being read by a 64 bit process.  Use the native pointer size
+   * in gdb itself to determine the auxv field size.	
+   *
+   * const int sizeof_auxv_field = TYPE_LENGTH (builtin_type_void_data_ptr);
+   */
+  const int sizeof_auxv_field = sizeof (void *);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
@@ -91,7 +99,20 @@
   if (endptr - ptr < sizeof_auxv_field * 2)
     return -1;
 
-  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  if (sizeof_auxv_field == 8 && gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) {
+    /*
+     * On 64 bit Solaris SPARC, i.e. big endian, the type will be in
+     * the left 4 bytes for 32 bit processes and the right 4 bytes
+     * for 64 bit processes.  The padding is 0.
+     */
+    *typep = extract_unsigned_integer (ptr, 4);
+    if (*typep == 0) *typep = extract_unsigned_integer (ptr + 4, 4);
+  } else {
+    /*
+     * Nothing special needs to be done on 32 bit or little endian systems.
+     */
+    *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+  }
   ptr += sizeof_auxv_field;
   *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
   ptr += sizeof_auxv_field;