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