RFA: MIPS ABI selection
Daniel Jacobowitz
drow@mvista.com
Sun Jun 9 12:37:00 GMT 2002
On Sun, Jun 09, 2002 at 03:15:16PM -0400, Andrew Cagney wrote:
> >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?
>
> Hmm, this contains several changes:
>
>
> -- The function mips_find_abi_section() that better identifies the ABI.
>
> Yes. This is definitly a good idea and approved.
Committed this version.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2002-06-08 Daniel Jacobowitz <drow@mvista.com>
* mips-tdep.c (mips_find_abi_section): New function.
(mips_gdbarch_init): Call it.
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
More information about the Gdb-patches
mailing list