Approved by Daniel Jacobowitz.
authorFred Fish <fnf@specifix.com>
Tue, 13 Jun 2006 18:17:20 +0000 (18:17 +0000)
committerFred Fish <fnf@specifix.com>
Tue, 13 Jun 2006 18:17:20 +0000 (18:17 +0000)
2006-06-13  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.

gdb/ChangeLog
gdb/mips-tdep.c

index a33484fef8f537038429b7c45d5dec3b8af57034..53d6a23a365108fcf399c6deef3a957a1b190138 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-13  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.
+
 2006-06-13  Nathan Sidwell  <nathan@codesourcery.com>
 
        * remote-file.io.c (remote_fileio_func_system): Treat zero length
index f815512c8d95a8a49a49bf0eacf04da6c12e2a5a..2cdbd70fbcf017f41df09151ee9f0f5baad6ff46 100644 (file)
@@ -4690,6 +4690,20 @@ mips_find_abi_section (bfd *abfd, asection *sect, void *obj)
     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)
 {
@@ -5009,6 +5023,58 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       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:
This page took 0.033098 seconds and 4 git commands to generate.