From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7913 invoked by alias); 9 Jun 2002 19:37:26 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 7877 invoked from network); 9 Jun 2002 19:37:23 -0000 Received: from unknown (HELO nevyn.them.org) (66.19.120.21) by sources.redhat.com with SMTP; 9 Jun 2002 19:37:23 -0000 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17H8Rr-0003sy-00 for ; Sun, 09 Jun 2002 15:33:59 -0400 Date: Sun, 09 Jun 2002 12:37:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: Re: RFA: MIPS ABI selection Message-ID: <20020609193359.GA14920@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com References: <20020609031656.GA2529@nevyn.them.org> <3D03A944.1000704@cygnus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D03A944.1000704@cygnus.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-06/txt/msg00154.txt.bz2 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 * 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