This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: MIPS ABI selection


The current state of the world in GCC says: a handful of setups default to
unique ABIs, but the global default is O32.  The default is also to pass no
ABI flags to the assembler.

elf64.h, iris6.h, isa3264.h, and r3900.h override this.  Irix defaults to
N32 and passing -n32 which presumably tags binaries; plus the irix
configuration in GDB can handle this.  elf64.h does not do pass any flags
but defaults to O64.  isa3264.h defaults to MEABI and appears not to tag
binaries.  r3900.h defaults to EABI and untagged binaries.

That's mipsisa32-*-elf*, mips64*-*-elf*, mipstx39*-*-elf*,
mips-sgi-irix5cross64, and mips-sgi-irix6*.

So what's a debugger to do?  Right now, we try to infer things from our
header files, but only little details of the ABI.  In particular, we never
infer O32 correctly.  Better would be to match GCC; that's quite
straightforward.

I skipped mipsisa32-*-elf*, because GDB doesn't support MEABI.  So this
patch fixes the defaults for mips64*-*-elf* and mipstx39*-*-elf*, and a
little tweaking for IRIX.  It then adds a global O32 default.  In the
process I found another way that GCC tags binaries with their ABI: a
".mdebug.abi32", etc. section.  I handle that too.  All appears to work like
a charm.  We even get warnings for MEABI etc. binaries.

Andrew, this look OK?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-06-08  Daniel Jacobowitz  <drow@mvista.com>

	* config/mips/embed64elf.mt: New file.
	* config/mips/tm-embed64elf.h: New file.
	* config/mips/embedl64elf.mt: New file.
	* config/mips/tm-embedl64elf.h: New file.
	* config/mips/irix5cross64.mt: New file.
	* config/mips/irix5cross64.mh: New file.
	* config/mips/tm-irix5c64.h: New file.
	* configure.tgt: Add mips*-sgi-irix5cross64, update
	mips64*el-*-elf* and mips64*-*-elf*.
	* mips-tdep.c (mips_find_abi_section): New function.
	(mips_gdbarch_init): Call it.  Use MIPS_DEFAULT_ABI
	unconditionally.  Replace default case in ABI switch
	with an error.
	* config/mips/tm-irix5.h: Recognize MIPS_USE_N32.  Undef
	MIPS_DEFAULT_ABI before defining.
	* config/mips/tm-linux.h: Remove MIPS_DEFAULT_ABI definition.
	* config/mips/tm-nbsd.h: Likewise.
	* config/mips/tm-mips.h: Define MIPS_DEFAULT_ABI.
	* config/mips/tm-tx39.h: Likewise.
	* config/mips/tm-tx39l.h: Likewise.
	
	* config/djgpp/fnchange.lst: Update.

Index: config/mips/embed64elf.mt
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/embed64elf.mt
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/embed64elf.mt	Sat Jun  8 15:00:21 2002
@@ -0,0 +1,5 @@
+# Target: Big-endian MIPS64 board.
+TDEPFILES= mips-tdep.o remote-mips.o remote-array.o
+TM_FILE= tm-embed64elf.h
+SIM_OBS = remote-sim.o
+SIM = ../sim/mips/libsim.a
Index: config/mips/tm-embed64elf.h
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/tm-embed64elf.h
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/tm-embed64elf.h	Sat Jun  8 22:11:11 2002
@@ -0,0 +1,23 @@
+/* Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "mips/tm-bigmips64.h"
+
+#undef MIPS_DEFAULT_ABI
+#define MIPS_DEFAULT_ABI MIPS_ABI_O64
Index: config/mips/tm-embedl64elf.h
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/tm-embedl64elf.h
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/tm-embedl64elf.h	Sat Jun  8 22:11:21 2002
@@ -0,0 +1,23 @@
+/* Copyright 2002 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "mips/tm-mips64.h"
+
+#undef MIPS_DEFAULT_ABI
+#define MIPS_DEFAULT_ABI MIPS_ABI_O64
Index: config/mips/embedl64elf.mt
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/embedl64elf.mt
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/embedl64elf.mt	Sat Jun  8 15:02:41 2002
@@ -0,0 +1,5 @@
+# Target: Little-endian MIPS64 board.
+TDEPFILES= mips-tdep.o remote-mips.o remote-array.o
+TM_FILE= tm-embedl64elf.h
+SIM_OBS = remote-sim.o
+SIM = ../sim/mips/libsim.a
Index: config/mips/irix5cross64.mt
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/irix5cross64.mt
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/irix5cross64.mt	Sat Jun  8 22:02:10 2002
@@ -0,0 +1,3 @@
+# Target: MIPS SGI running Irix 5
+TDEPFILES= mips-tdep.o
+TM_FILE= tm-irix5c64.h
Index: config/mips/irix5cross64.mh
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/irix5cross64.mh
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/irix5cross64.mh	Sat Jun  8 21:55:16 2002
@@ -0,0 +1,7 @@
+# Host: SGI Iris running irix 5.x
+XM_FILE= xm-irix5.h
+NAT_FILE= nm-irix5.h
+NATDEPFILES= fork-child.o irix5-nat.o corelow.o procfs.o \
+	proc-api.o proc-events.o proc-flags.o proc-why.o
+
+XM_CLIBS=-lbsd -lsun
Index: config/mips/tm-irix5c64.h
===================================================================
RCS file: N/A
diff -u /dev/null config/mips/tm-irix5c64.h
--- /dev/null	Wed Dec 31 19:00:00 1969
+++ config/mips/tm-irix5c64.h	Sat Jun  8 22:10:42 2002
@@ -0,0 +1,24 @@
+/* Target machine description for SGI Iris under Irix 5, using N32, for GDB.
+   Copyright 2002
+   Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define MIPS_USE_N32 1
+
+#include "mips/tm-irix5.h"
Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.68
diff -u -p -r1.68 configure.tgt
--- configure.tgt	31 May 2002 00:59:13 -0000	1.68
+++ configure.tgt	9 Jun 2002 03:09:31 -0000
@@ -186,14 +186,15 @@ mips64*vr5000*el-*-elf*)	gdb_target=vr50
 mips64*vr5000*-*-elf*)	gdb_target=vr5000 ;;
 mips*tx39*el*-elf*)	gdb_target=tx39l ;;
 mips*tx39*-elf*)	gdb_target=tx39 ;;
-mips64*el-*-elf*)	gdb_target=embedl64 ;;
-mips64*-*-elf*)		gdb_target=embed64 ;;
+mips64*el-*-elf*)	gdb_target=embedl64elf ;;
+mips64*-*-elf*)		gdb_target=embed64elf ;;
 mips*el-*-ecoff*)	gdb_target=embedl ;;
 mips*-*-ecoff*)		gdb_target=embed ;;
 mips*el-*-elf*)		gdb_target=embedl ;;
 mips*-*-elf*)		gdb_target=embed ;;
 mips*-little-*)		gdb_target=littlemips ;;
 mips*-*-lnews*)		gdb_target=embedl ;;
+mips*-sgi-irix5cross64)	gdb_target=irix5cross64 ;;
 mips*-sgi-irix5*)	gdb_target=irix5 ;;
 mips*-sgi-irix6*)	gdb_target=irix6 ;;
 mips*-sgi-*)		gdb_target=irix3 ;;
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.74
diff -u -p -r1.74 mips-tdep.c
--- mips-tdep.c	21 May 2002 15:36:03 -0000	1.74
+++ mips-tdep.c	9 Jun 2002 03:09:50 -0000
@@ -4126,6 +4126,32 @@ mips_integer_to_address (struct type *ty
 				 TYPE_LENGTH (builtin_type_void_data_ptr));
 }
 
+static void
+mips_find_abi_section (bfd *abfd, asection *sect, void *obj)
+{
+  enum mips_abi *abip = (enum mips_abi *) obj;
+  const char *name = bfd_get_section_name (abfd, sect);
+
+  if (*abip != MIPS_ABI_UNKNOWN)
+    return;
+
+  if (strncmp (name, ".mdebug.", 8) != 0)
+    return;
+
+  if (strcmp (name, ".mdebug.abi32") == 0)
+    *abip = MIPS_ABI_O32;
+  else if (strcmp (name, ".mdebug.abiN32") == 0)
+    *abip = MIPS_ABI_N32;
+  else if (strcmp (name, ".mdebug.abiO64") == 0)
+    *abip = MIPS_ABI_O64;
+  else if (strcmp (name, ".mdebug.eabi32") == 0)
+    *abip = MIPS_ABI_EABI32;
+  else if (strcmp (name, ".mdebug.eabi64") == 0)
+    *abip = MIPS_ABI_EABI64;
+  else
+    warning ("unsupported ABI %s.", name + 8);
+}
+
 static struct gdbarch *
 mips_gdbarch_init (struct gdbarch_info info,
 		   struct gdbarch_list *arches)
@@ -4180,6 +4206,10 @@ mips_gdbarch_init (struct gdbarch_info i
       break;
     }
 
+  /* GCC creates a pseudo-section whose name describes the ABI.  */
+  if (mips_abi == MIPS_ABI_UNKNOWN && info.abfd != NULL)
+    bfd_map_over_sections (info.abfd, mips_find_abi_section, &mips_abi);
+
   /* Try the architecture for any hint of the corect ABI */
   if (mips_abi == MIPS_ABI_UNKNOWN
       && info.bfd_arch_info != NULL
@@ -4200,10 +4230,9 @@ mips_gdbarch_init (struct gdbarch_info i
 	  break;
 	}
     }
-#ifdef MIPS_DEFAULT_ABI
+
   if (mips_abi == MIPS_ABI_UNKNOWN)
     mips_abi = MIPS_DEFAULT_ABI;
-#endif
 
   if (gdbarch_debug)
     {
@@ -4329,18 +4358,7 @@ mips_gdbarch_init (struct gdbarch_info i
 	tm_print_insn_info.mach = bfd_mach_mips8000;
       break;
     default:
-      tdep->mips_abi_string = "default";
-      tdep->mips_default_saved_regsize = MIPS_REGSIZE;
-      tdep->mips_default_stack_argsize = MIPS_REGSIZE;
-      tdep->mips_fp_register_double = (REGISTER_VIRTUAL_SIZE (FP0_REGNUM) == 8);
-      tdep->mips_last_arg_regnum = A0_REGNUM + 8 - 1;
-      tdep->mips_last_fp_arg_regnum = FPA0_REGNUM + 8 - 1;
-      tdep->mips_regs_have_home_p = 1;
-      tdep->gdb_target_is_mips64 = 0;
-      tdep->default_mask_address_p = 0;
-      set_gdbarch_long_bit (gdbarch, 32);
-      set_gdbarch_ptr_bit (gdbarch, 32);
-      set_gdbarch_long_long_bit (gdbarch, 64);
+      internal_error (__FILE__, __LINE__, "Unknown MIPS ABI");
       break;
     }
 
Index: config/djgpp/fnchange.lst
===================================================================
RCS file: /cvs/src/src/gdb/config/djgpp/fnchange.lst,v
retrieving revision 1.31
diff -u -p -r1.31 fnchange.lst
--- config/djgpp/fnchange.lst	8 Jun 2002 19:34:00 -0000	1.31
+++ config/djgpp/fnchange.lst	9 Jun 2002 03:09:52 -0000
@@ -92,10 +92,14 @@
 @V@/gdb/config/m68k/xm-hp300hpux.h @V@/gdb/config/m68k/xm-300ux.h
 @V@/gdb/config/m88k/tm-delta88v4.h @V@/gdb/config/m88k/tm-d88v4.h
 @V@/gdb/config/m88k/xm-delta88v4.h @V@/gdb/config/m88k/xm-d88v4.h
+@V@/gdb/config/mips/embedl64elf.mt @V@/gdb/config/mips/embl64elf.mt
 @V@/gdb/config/mips/tm-bigmips64.h @V@/gdb/config/mips/tm-bigm64.h
 @V@/gdb/config/mips/tm-embed64.h @V@/gdb/config/mips/tm-emb64.h
+@V@/gdb/config/mips/tm-embed64elf.h @V@/gdb/config/mips/tm-em64e.h
 @V@/gdb/config/mips/tm-embedl.h @V@/gdb/config/mips/tm-embdl.h
 @V@/gdb/config/mips/tm-embedl64.h @V@/gdb/config/mips/tm-embl64.h
+@V@/gdb/config/mips/tm-embedl64elf.h @V@/gdb/config/mips/tm-el64e.h
+@V@/gdb/config/mips/tm-irix5c64.h @V@/gdb/config/mips/tm-ir5c64.h
 @V@/gdb/config/mips/tm-vr4300el.h @V@/gdb/config/mips/tm-v43el.h
 @V@/gdb/config/mips/tm-vr4xxxel.h @V@/gdb/config/mips/tm-v4xel.h
 @V@/gdb/config/mips/tm-vr5000el.h @V@/gdb/config/mips/tm-vr5kel.h
Index: config/mips/tm-irix5.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-irix5.h,v
retrieving revision 1.6
diff -u -p -r1.6 tm-irix5.h
--- config/mips/tm-irix5.h	6 Mar 2001 08:21:32 -0000	1.6
+++ config/mips/tm-irix5.h	9 Jun 2002 03:09:54 -0000
@@ -25,7 +25,7 @@
    _MIPS_SIM in a tm-*.h file is simply wrong!  Those are
    host-dependant macros (provided by /usr/include) and stop any
    chance of the target being cross compiled */
-#if defined (_MIPS_SIM_NABI32) && _MIPS_SIM == _MIPS_SIM_NABI32
+#if defined (MIPS_USE_N32) || (defined (_MIPS_SIM_NABI32) && _MIPS_SIM == _MIPS_SIM_NABI32)
 /*
  * Irix 6 (n32 ABI) has 32-bit GP regs and 64-bit FP regs
  */
@@ -61,6 +61,7 @@
 #define MIPS_REGS_HAVE_HOME_P 0
 
 /* Force N32 ABI as the default. */
+#undef MIPS_DEFAULT_ABI
 #define MIPS_DEFAULT_ABI MIPS_ABI_N32
 
 #endif /* N32 */
Index: config/mips/tm-irix6.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-irix6.h,v
retrieving revision 1.1
diff -u -p -r1.1 tm-irix6.h
--- config/mips/tm-irix6.h	7 Jun 2001 15:57:57 -0000	1.1
+++ config/mips/tm-irix6.h	9 Jun 2002 03:09:55 -0000
@@ -108,8 +108,8 @@
 #define MIPS_REGS_HAVE_HOME_P 0
 
 /* Force N32 ABI as the default. */
+#undef MIPS_DEFAULT_ABI
 #define MIPS_DEFAULT_ABI MIPS_ABI_N32
-
 
 /* The signal handler trampoline is called _sigtramp.  */
 #undef IN_SIGTRAMP
Index: config/mips/tm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-linux.h,v
retrieving revision 1.4
diff -u -p -r1.4 tm-linux.h
--- config/mips/tm-linux.h	5 Jun 2002 19:18:25 -0000	1.4
+++ config/mips/tm-linux.h	9 Jun 2002 03:09:55 -0000
@@ -38,11 +38,6 @@
 
 #include "config/tm-linux.h"
 
-/* There's an E_MIPS_ABI_O32 flag in e_flags, but we don't use it - in
-   fact, using it may violate the o32 ABI.  */
-
-#define MIPS_DEFAULT_ABI MIPS_ABI_O32
-
 /* Use target_specific function to define link map offsets.  */
 
 extern struct link_map_offsets *mips_linux_svr4_fetch_link_map_offsets (void);
Index: config/mips/tm-mips.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-mips.h,v
retrieving revision 1.25
diff -u -p -r1.25 tm-mips.h
--- config/mips/tm-mips.h	10 Feb 2002 07:17:17 -0000	1.25
+++ config/mips/tm-mips.h	9 Jun 2002 03:09:57 -0000
@@ -55,6 +55,11 @@ struct value;
 
 #define DEFAULT_MIPS_TYPE "generic"
 
+/* The default ABI for MIPS binaries.  */
+#ifndef MIPS_DEFAULT_ABI
+#define MIPS_DEFAULT_ABI MIPS_ABI_O32
+#endif
+
 /* Remove useless bits from the stack pointer.  */
 
 #define TARGET_READ_SP() ADDR_BITS_REMOVE (read_register (SP_REGNUM))
Index: config/mips/tm-nbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-nbsd.h,v
retrieving revision 1.1
diff -u -p -r1.1 tm-nbsd.h
--- config/mips/tm-nbsd.h	21 May 2002 15:58:41 -0000	1.1
+++ config/mips/tm-nbsd.h	9 Jun 2002 03:09:57 -0000
@@ -28,11 +28,6 @@
 #include "mips/tm-mips.h"
 #include "solib.h"
 
-/* There's an E_MIPS_ABI_O32 flag in e_flags, but we don't use it - in
-   fact, using it may violate the o32 ABI.  */
-
-#define MIPS_DEFAULT_ABI MIPS_ABI_O32
-
 /* We don't want to inherit tm-mips.h's shared library trampoline code.  */
 #undef IN_SOLIB_CALL_TRAMPOLINE
 #undef IN_SOLIB_RETURN_TRAMPOLINE
Index: config/mips/tm-tx39.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-tx39.h,v
retrieving revision 1.5
diff -u -p -r1.5 tm-tx39.h
--- config/mips/tm-tx39.h	6 Mar 2001 08:21:32 -0000	1.5
+++ config/mips/tm-tx39.h	9 Jun 2002 03:09:57 -0000
@@ -19,6 +19,9 @@
 
 #include "mips/tm-bigmips.h"
 
+#undef MIPS_DEFAULT_ABI
+#define MIPS_DEFAULT_ABI MIPS_EABI32
+
 #undef  MIPS_REGISTER_NAMES
 #define MIPS_REGISTER_NAMES 	\
     {	"zero",	"at",	"v0",	"v1",	"a0",	"a1",	"a2",	"a3", \
Index: config/mips/tm-tx39l.h
===================================================================
RCS file: /cvs/src/src/gdb/config/mips/tm-tx39l.h,v
retrieving revision 1.5
diff -u -p -r1.5 tm-tx39l.h
--- config/mips/tm-tx39l.h	6 Mar 2001 08:21:32 -0000	1.5
+++ config/mips/tm-tx39l.h	9 Jun 2002 03:09:57 -0000
@@ -19,6 +19,9 @@
 
 #include "mips/tm-mips.h"
 
+#undef MIPS_DEFAULT_ABI
+#define MIPS_DEFAULT_ABI MIPS_EABI32
+
 #undef  MIPS_REGISTER_NAMES
 #define MIPS_REGISTER_NAMES 	\
     {	"zero",	"at",	"v0",	"v1",	"a0",	"a1",	"a2",	"a3", \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]