Blame SOURCES/gdb-rhbz1125820-ppc64le-enablement-29of37.patch

2c2fa1
commit cd453cd072004d26ede355b850b3831acffaeddd
2c2fa1
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2c2fa1
Date:   Tue Feb 4 18:38:56 2014 +0100
2c2fa1
2c2fa1
    PowerPC64 ELFv2 ABI: base support
2c2fa1
    
2c2fa1
    This is the first patch of a series to implement support for the
2c2fa1
    PowerPC ELFv2 ABI.  While powerpc64le-linux will use ELFv2, and
2c2fa1
    the existing powerpc64-linux code will continue to use ELFv1,
2c2fa1
    in theory ELFv2 is also defined for big-endian systems (and
2c2fa1
    ELFv1 was also defined for little-endian systems).
2c2fa1
    
2c2fa1
    Therefore this patch adds a new tdep->elf_abi variable to decide
2c2fa1
    which ABI version to use.  This is detected from the ELF header
2c2fa1
    e_flags value; if this is not present, we default to ELFv2 on
2c2fa1
    little-endian and ELFv1 otherwise.
2c2fa1
    
2c2fa1
    This patch does not yet introduce any actual difference in GDB's
2c2fa1
    handling of the two ABIs.  Those will be added by the remainder
2c2fa1
    of this patch series.
2c2fa1
    
2c2fa1
    For an overview of the changes in ELFv2, have a look at the
2c2fa1
    comments in the patch series that added ELFv2 to GCC, starting at:
2c2fa1
    http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01144.html
2c2fa1
    
2c2fa1
    gdb/ChangeLog:
2c2fa1
    
2c2fa1
    	* ppc-tdep.h (enum powerpc_elf_abi): New data type.
2c2fa1
    	(struct gdbarch_tdep): New member elf_abi.
2c2fa1
    
2c2fa1
    	* rs6000-tdep.c: Include "elf/ppc64.h".
2c2fa1
    	(rs6000_gdbarch_init): Detect ELF ABI version.
2c2fa1
2c2fa1
Index: gdb-7.6.1/gdb/ppc-tdep.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/ppc-tdep.h
2c2fa1
+++ gdb-7.6.1/gdb/ppc-tdep.h
2c2fa1
@@ -182,6 +182,15 @@ extern void ppc_collect_vsxregset (const
2c2fa1
 
2c2fa1
 /* Private data that this module attaches to struct gdbarch.  */
2c2fa1
 
2c2fa1
+/* ELF ABI version used by the inferior.  */
2c2fa1
+enum powerpc_elf_abi
2c2fa1
+{
2c2fa1
+  POWERPC_ELF_AUTO,
2c2fa1
+  POWERPC_ELF_V1,
2c2fa1
+  POWERPC_ELF_V2,
2c2fa1
+  POWERPC_ELF_LAST
2c2fa1
+};
2c2fa1
+
2c2fa1
 /* Vector ABI used by the inferior.  */
2c2fa1
 enum powerpc_vector_abi
2c2fa1
 {
2c2fa1
@@ -197,6 +206,8 @@ struct gdbarch_tdep
2c2fa1
     int wordsize;		/* Size in bytes of fixed-point word.  */
2c2fa1
     int soft_float;		/* Avoid FP registers for arguments?  */
2c2fa1
 
2c2fa1
+    enum powerpc_elf_abi elf_abi;	/* ELF ABI version.  */
2c2fa1
+
2c2fa1
     /* How to pass vector arguments.  Never set to AUTO or LAST.  */
2c2fa1
     enum powerpc_vector_abi vector_abi;
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/rs6000-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/rs6000-tdep.c
2c2fa1
+++ gdb-7.6.1/gdb/rs6000-tdep.c
2c2fa1
@@ -48,6 +48,7 @@
2c2fa1
 
2c2fa1
 #include "elf-bfd.h"
2c2fa1
 #include "elf/ppc.h"
2c2fa1
+#include "elf/ppc64.h"
2c2fa1
 
2c2fa1
 #include "solib-svr4.h"
2c2fa1
 #include "ppc-tdep.h"
2c2fa1
@@ -3605,6 +3606,7 @@ rs6000_gdbarch_init (struct gdbarch_info
2c2fa1
   enum auto_boolean soft_float_flag = powerpc_soft_float_global;
2c2fa1
   int soft_float;
2c2fa1
   enum powerpc_vector_abi vector_abi = powerpc_vector_abi_global;
2c2fa1
+  enum powerpc_elf_abi elf_abi = POWERPC_ELF_AUTO;
2c2fa1
   int have_fpu = 1, have_spe = 0, have_mq = 0, have_altivec = 0, have_dfp = 0,
2c2fa1
       have_vsx = 0;
2c2fa1
   int tdesc_wordsize = -1;
2c2fa1
@@ -3911,6 +3913,21 @@ rs6000_gdbarch_init (struct gdbarch_info
2c2fa1
     }
2c2fa1
 
2c2fa1
 #ifdef HAVE_ELF
2c2fa1
+  if (from_elf_exec)
2c2fa1
+    {
2c2fa1
+      switch (elf_elfheader (info.abfd)->e_flags & EF_PPC64_ABI)
2c2fa1
+	{
2c2fa1
+	case 1:
2c2fa1
+	  elf_abi = POWERPC_ELF_V1;
2c2fa1
+	  break;
2c2fa1
+	case 2:
2c2fa1
+	  elf_abi = POWERPC_ELF_V2;
2c2fa1
+	  break;
2c2fa1
+	default:
2c2fa1
+	  break;
2c2fa1
+	}
2c2fa1
+    }
2c2fa1
+
2c2fa1
   if (soft_float_flag == AUTO_BOOLEAN_AUTO && from_elf_exec)
2c2fa1
     {
2c2fa1
       switch (bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
2c2fa1
@@ -3947,6 +3964,21 @@ rs6000_gdbarch_init (struct gdbarch_info
2c2fa1
     }
2c2fa1
 #endif
2c2fa1
 
2c2fa1
+  /* At this point, the only supported ELF-based 64-bit little-endian
2c2fa1
+     operating system is GNU/Linux, and this uses the ELFv2 ABI by
2c2fa1
+     default.  All other supported ELF-based operating systems use the
2c2fa1
+     ELFv1 ABI by default.  Therefore, if the ABI marker is missing,
2c2fa1
+     e.g. because we run a legacy binary, or have attached to a process
2c2fa1
+     and have not found any associated binary file, set the default
2c2fa1
+     according to this heuristic.  */
2c2fa1
+  if (elf_abi == POWERPC_ELF_AUTO)
2c2fa1
+    {
2c2fa1
+      if (wordsize == 8 && info.byte_order == BFD_ENDIAN_LITTLE)
2c2fa1
+        elf_abi = POWERPC_ELF_V2;
2c2fa1
+      else
2c2fa1
+        elf_abi = POWERPC_ELF_V1;
2c2fa1
+    }
2c2fa1
+
2c2fa1
   if (soft_float_flag == AUTO_BOOLEAN_TRUE)
2c2fa1
     soft_float = 1;
2c2fa1
   else if (soft_float_flag == AUTO_BOOLEAN_FALSE)
2c2fa1
@@ -3989,6 +4021,8 @@ rs6000_gdbarch_init (struct gdbarch_info
2c2fa1
          meaningful, because 64-bit CPUs can run in 32-bit mode.  So, perform
2c2fa1
          separate word size check.  */
2c2fa1
       tdep = gdbarch_tdep (arches->gdbarch);
2c2fa1
+      if (tdep && tdep->elf_abi != elf_abi)
2c2fa1
+	continue;
2c2fa1
       if (tdep && tdep->soft_float != soft_float)
2c2fa1
 	continue;
2c2fa1
       if (tdep && tdep->vector_abi != vector_abi)
2c2fa1
@@ -4011,6 +4045,7 @@ rs6000_gdbarch_init (struct gdbarch_info
2c2fa1
 
2c2fa1
   tdep = XCALLOC (1, struct gdbarch_tdep);
2c2fa1
   tdep->wordsize = wordsize;
2c2fa1
+  tdep->elf_abi = elf_abi;
2c2fa1
   tdep->soft_float = soft_float;
2c2fa1
   tdep->vector_abi = vector_abi;
2c2fa1