* elflink.h (elf_bfd_final_link): Check if dynobj is not NULL
[binutils-gdb.git] / gdb / arch-utils.c
index 60c830160111d67a8784bf11c18d6fbeada6548d..175f85eb3d8759ba29339a0ddd4a0a7ee966d63a 100644 (file)
@@ -21,6 +21,7 @@
 #include "defs.h"
 
 #if GDB_MULTI_ARCH
+#include "arch-utils.h"
 #include "gdbcmd.h"
 #include "inferior.h"          /* enum CALL_DUMMY_LOCATION et.al. */
 #else
@@ -195,7 +196,7 @@ default_float_format (struct gdbarch *gdbarch)
     {
     case BIG_ENDIAN:
       return &floatformat_ieee_single_big;
-    case LITTLE_ENDIAN:
+    case BFD_ENDIAN_LITTLE:
       return &floatformat_ieee_single_little;
     default:
       internal_error (__FILE__, __LINE__,
@@ -216,7 +217,7 @@ default_double_format (struct gdbarch *gdbarch)
     {
     case BIG_ENDIAN:
       return &floatformat_ieee_double_big;
-    case LITTLE_ENDIAN:
+    case BFD_ENDIAN_LITTLE:
       return &floatformat_ieee_double_little;
     default:
       internal_error (__FILE__, __LINE__,
@@ -387,6 +388,14 @@ generic_register_raw_size (int regnum)
   return TARGET_INT_BIT / HOST_CHAR_BIT;
 }
 
+/* Assume the virtual size corresponds to the virtual type.  */
+
+int
+generic_register_virtual_size (int regnum)
+{
+  return TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (regnum));
+}
+
 \f
 /* Functions to manipulate the endianness of the target.  */
 
@@ -458,8 +467,8 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
       if (GDB_MULTI_ARCH)
        {
          struct gdbarch_info info;
-         memset (&info, 0, sizeof info);
-         info.byte_order = LITTLE_ENDIAN;
+         gdbarch_info_init (&info);
+         info.byte_order = BFD_ENDIAN_LITTLE;
          if (! gdbarch_update_p (info))
            {
              printf_unfiltered ("Little endian target not supported by GDB\n");
@@ -467,7 +476,7 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
        }
       else
        {
-         target_byte_order = LITTLE_ENDIAN;
+         target_byte_order = BFD_ENDIAN_LITTLE;
        }
     }
   else if (set_endian_string == endian_big)
@@ -476,7 +485,7 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
       if (GDB_MULTI_ARCH)
        {
          struct gdbarch_info info;
-         memset (&info, 0, sizeof info);
+         gdbarch_info_init (&info);
          info.byte_order = BIG_ENDIAN;
          if (! gdbarch_update_p (info))
            {
@@ -509,7 +518,7 @@ set_endian_from_file (bfd *abfd)
       if (bfd_big_endian (abfd))
        want = BIG_ENDIAN;
       else
-       want = LITTLE_ENDIAN;
+       want = BFD_ENDIAN_LITTLE;
       if (TARGET_BYTE_ORDER_AUTO)
        target_byte_order = want;
       else if (TARGET_BYTE_ORDER != want)
@@ -655,7 +664,7 @@ set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
   else if (GDB_MULTI_ARCH)
     {
       struct gdbarch_info info;
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
       if (info.bfd_arch_info == NULL)
        internal_error (__FILE__, __LINE__,
@@ -687,7 +696,7 @@ set_gdbarch_from_file (bfd *abfd)
   if (GDB_MULTI_ARCH)
     {
       struct gdbarch_info info;
-      memset (&info, 0, sizeof info);
+      gdbarch_info_init (&info);
       info.abfd = abfd;
       if (! gdbarch_update_p (info))
        error ("Architecture of file not recognized.\n");
@@ -724,7 +733,7 @@ initialize_current_architecture (void)
 
   /* determine a default architecture and byte order. */
   struct gdbarch_info info;
-  memset (&info, 0, sizeof (info));
+  gdbarch_info_init (&info);
   
   /* Find a default architecture. */
   if (info.bfd_arch_info == NULL
@@ -753,7 +762,7 @@ initialize_current_architecture (void)
   /* take several guesses at a byte order. */
   /* NB: can't use TARGET_BYTE_ORDER_DEFAULT as its definition is
      forced above. */
-  if (info.byte_order == 0
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN
       && default_bfd_vec != NULL)
     {
       /* Extract BFD's default vector's byte order. */
@@ -763,13 +772,13 @@ initialize_current_architecture (void)
          info.byte_order = BIG_ENDIAN;
          break;
        case BFD_ENDIAN_LITTLE:
-         info.byte_order = LITTLE_ENDIAN;
+         info.byte_order = BFD_ENDIAN_LITTLE;
          break;
        default:
          break;
        }
     }
-  if (info.byte_order == 0)
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     {
       /* look for ``*el-*'' in the target name. */
       const char *chp;
@@ -777,9 +786,9 @@ initialize_current_architecture (void)
       if (chp != NULL
          && chp - 2 >= target_name
          && strncmp (chp - 2, "el", 2) == 0)
-       info.byte_order = LITTLE_ENDIAN;
+       info.byte_order = BFD_ENDIAN_LITTLE;
     }
-  if (info.byte_order == 0)
+  if (info.byte_order == BFD_ENDIAN_UNKNOWN)
     {
       /* Wire it to big-endian!!! */
       info.byte_order = BIG_ENDIAN;
@@ -823,6 +832,19 @@ initialize_current_architecture (void)
 }
 
 
+/* Initialize a gdbarch info to values that will be automatically
+   overridden.  Note: Originally, this ``struct info'' was initialized
+   using memset(0).  Unfortunatly, that ran into problems, namely
+   BFD_ENDIAN_BIG is zero.  An explicit initialization function that
+   can explicitly set each field to a well defined value is used.  */
+
+void
+gdbarch_info_init (struct gdbarch_info *info)
+{
+  memset (info, 0, sizeof (struct gdbarch_info));
+  info->byte_order = BFD_ENDIAN_UNKNOWN;
+}
+
 /* */
 
 extern initialize_file_ftype _initialize_gdbarch_utils;