This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [RFC] Passing MIPS debug hints between gcc and gdb


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  <fnf@specifix.com>

	* 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  <fnf@specifix.com>

	* 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:


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