From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29489 invoked by alias); 12 Jun 2006 10:10:05 -0000 Received: (qmail 29477 invoked by uid 22791); 12 Jun 2006 10:10:04 -0000 X-Spam-Check-By: sourceware.org Received: from w099.z064220152.sjc-ca.dsl.cnc.net (HELO duck.specifix.com) (64.220.152.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 12 Jun 2006 10:09:59 +0000 Received: from localhost (duck.specifix.com [64.220.152.99]) by duck.specifix.com (Postfix) with ESMTP id 6F71CFC81; Mon, 12 Jun 2006 03:09:53 -0700 (PDT) From: Fred Fish Reply-To: fnf@specifix.com To: Richard Sandiford Subject: Re: [RFC] Passing MIPS debug hints between gcc and gdb Date: Mon, 12 Jun 2006 10:10:00 -0000 User-Agent: KMail/1.9.1 Cc: gcc-patches@gcc.gnu.org, gdb-patches@sourceware.org, fnf@specifix.com References: <200605101206.01433.fnf@specifix.com> <87y7x9aw12.fsf@talisman.home> In-Reply-To: <87y7x9aw12.fsf@talisman.home> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606120611.32335.fnf@specifix.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00148.txt.bz2 On Thursday 11 May 2006 02:57, Richard Sandiford wrote: > Since both EABI and o64 are basically GNU inventions, I'd be OK with > relaxing the condition to EABI || o64 if it's o64 you need this for. OK, here is a gcc patch to do that, and a matching gdb patch to use it. If the gcc patch is approved, please check it in as I don't currently have gcc write access. -Fred %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2006-06-12 Fred Fish * config/mips/mips.c (mips_file_start): Create special section ".gcc_compiled_longXX" for o64 ABI as well as EABI. Index: config/mips/mips.c =================================================================== RCS file: /cvsroots/latest/src/gcc/gcc/config/mips/mips.c,v retrieving revision 1.1.1.9 diff -u -p -r1.1.1.9 mips.c --- config/mips/mips.c 11 May 2006 18:41:03 -0000 1.1.1.9 +++ config/mips/mips.c 11 Jun 2006 18:01:07 -0000 @@ -5831,7 +5831,8 @@ mips_file_start (void) /* There is no ELF header flag to distinguish long32 forms of the EABI from long64 forms. Emit a special section to help tools such as GDB. */ - if (mips_abi == ABI_EABI) + if (mips_abi == ABI_EABI + || mips_abi == ABI_O64) fprintf (asm_out_file, "\t.section .gcc_compiled_long%d\n", TARGET_LONG64 ? 64 : 32); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2006-06-12 Fred Fish * mips-tdep.c (mips_find_long_section): New function. (mips_gdbarch_init): Use it to set long and pointer sizes. Index: mips-tdep.c =================================================================== RCS file: /cvsroots/latest/src/gdb/gdb/mips-tdep.c,v retrieving revision 1.1.1.8 diff -c -p -r1.1.1.8 mips-tdep.c *** mips-tdep.c 10 Jun 2006 03:32:42 -0000 1.1.1.8 --- mips-tdep.c 11 Jun 2006 18:11:09 -0000 *************** mips_find_abi_section (bfd *abfd, asecti *** 4690,4695 **** --- 4690,4709 ---- warning (_("unsupported ABI %s."), name + 8); } + static void + mips_find_long_section (bfd *abfd, asection *sect, void *obj) + { + int *lbp = (int *) obj; + const char *name = bfd_get_section_name (abfd, sect); + + if (strncmp (name, ".gcc_compiled_long32", 20) == 0) + *lbp = 32; + else if (strncmp (name, ".gcc_compiled_long64", 20) == 0) + *lbp = 64; + else if (strncmp (name, ".gcc_compiled_long", 18) == 0) + warning (_("unrecognized .gcc_compiled_longXX")); + } + static enum mips_abi global_mips_abi (void) { *************** mips_gdbarch_init (struct gdbarch_info i *** 5009,5014 **** --- 5023,5080 ---- internal_error (__FILE__, __LINE__, _("unknown ABI in switch")); } + /* GCC creates a pseudo-section whose name specifies the size of + longs, since -mlong32 or -mlong64 may be used independent of + other options. How those options affect pointer sizes is ABI and + architecture dependent, so use them to override the default sizes + set by the ABI. This table shows the relationship between ABI, + -mlongXX, and size of pointers: + + ABI -mlongXX ptr bits + --- -------- -------- + o32 32 32 + o32 64 32 + n32 32 32 + n32 64 64 + o64 32 32 + o64 64 64 + n64 32 32 + n64 64 64 + eabi32 32 32 + eabi32 64 32 + eabi64 32 32 + eabi64 64 64 + + Note that for o32 and eabi32, pointers are always 32 bits + regardless of any -mlongXX option. For all others, pointers and + longs are the same, as set by -mlongXX or set by defaults. + */ + + if (info.abfd != NULL) + { + int long_bit = 0; + + bfd_map_over_sections (info.abfd, mips_find_long_section, &long_bit); + if (long_bit) + { + set_gdbarch_long_bit (gdbarch, long_bit); + switch (mips_abi) + { + case MIPS_ABI_O32: + case MIPS_ABI_EABI32: + break; + case MIPS_ABI_N32: + case MIPS_ABI_O64: + case MIPS_ABI_N64: + case MIPS_ABI_EABI64: + set_gdbarch_ptr_bit (gdbarch, long_bit); + break; + default: + internal_error (__FILE__, __LINE__, _("unknown ABI in switch")); + } + } + } + /* FIXME: jlarmour/2000-04-07: There *is* a flag EF_MIPS_32BIT_MODE that could indicate -gp32 BUT gas/config/tc-mips.c contains the comment: