usr/src/cmd/gdb/gdb.auxv.c.patch
changeset 46 9c200dad5ecc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/gdb/gdb.auxv.c.patch	Mon Sep 20 06:25:02 2010 -0700
@@ -0,0 +1,41 @@
+--- 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;