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

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