ld signed overflow fix
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index f99061d40db0246bff701467b3ddd19beca431d1..ecfae68427716333ab060ef1c44b3a25df9d7ac0 100644 (file)
@@ -9916,7 +9916,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
        {
          struct symbol *sym = list->symbol[i];
 
-         if (SYMBOL_LANGUAGE (sym) == language_go
+         if (sym->language () == language_go
              && SYMBOL_CLASS (sym) == LOC_BLOCK)
            {
              char *this_package_name = go_symbol_package_name (sym);
@@ -9952,7 +9952,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       struct symbol *sym;
 
       sym = allocate_symbol (objfile);
-      SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
+      sym->set_language (language_go, &objfile->objfile_obstack);
       SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile);
       /* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
         e.g., "main" finds the "main" module and not C's main().  */
@@ -15127,7 +15127,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
       attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
       if (attr != nullptr)
        {
-         if (gdbarch_bits_big_endian (gdbarch))
+         if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
            {
              /* For big endian bits, the DW_AT_bit_offset gives the
                 additional bit offset from the MSB of the containing
@@ -17624,7 +17624,7 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
 
 static struct type *
 dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
-                       const char *name_hint)
+                       const char *name_hint, enum bfd_endian byte_order)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   const struct floatformat **format;
@@ -17632,7 +17632,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
 
   format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
   if (format)
-    type = init_float_type (objfile, bits, name, format);
+    type = init_float_type (objfile, bits, name, format, byte_order);
   else
     type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
 
@@ -17671,7 +17671,8 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile,
 static struct type *
 dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
                                 struct objfile *objfile,
-                                int bits, const char *name_hint)
+                                int bits, const char *name_hint,
+                                enum bfd_endian byte_order)
 {
   gdbarch *gdbarch = get_objfile_arch (objfile);
   struct type *tt = nullptr;
@@ -17720,7 +17721,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu,
     tt = nullptr;
 
   const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);
-  return dwarf2_init_float_type (objfile, bits, name, name_hint);
+  return dwarf2_init_float_type (objfile, bits, name, name_hint, byte_order);
 }
 
 /* Find a representation of a given base type and install
@@ -17733,7 +17734,6 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
   struct type *type;
   struct attribute *attr;
   int encoding = 0, bits = 0;
-  int endianity = 0;
   const char *name;
   gdbarch *arch;
 
@@ -17746,11 +17746,29 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
   name = dwarf2_name (die, cu);
   if (!name)
     complaint (_("DW_AT_name missing from DW_TAG_base_type"));
+
+  arch = get_objfile_arch (objfile);
+  enum bfd_endian byte_order = gdbarch_byte_order (arch);
+
   attr = dwarf2_attr (die, DW_AT_endianity, cu);
   if (attr)
-    endianity = DW_UNSND (attr);
+    {
+      int endianity = DW_UNSND (attr);
+
+      switch (endianity)
+       {
+       case DW_END_big:
+         byte_order = BFD_ENDIAN_BIG;
+         break;
+       case DW_END_little:
+         byte_order = BFD_ENDIAN_LITTLE;
+         break;
+       default:
+         complaint (_("DW_AT_endianity has unrecognized value %d"), endianity);
+         break;
+       }
+    }
 
-  arch = get_objfile_arch (objfile);
   switch (encoding)
     {
       case DW_ATE_address:
@@ -17762,14 +17780,15 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
        type = init_boolean_type (objfile, bits, 1, name);
        break;
       case DW_ATE_complex_float:
-       type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name);
+       type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name,
+                                               byte_order);
        type = init_complex_type (objfile, name, type);
        break;
       case DW_ATE_decimal_float:
        type = init_decfloat_type (objfile, bits, name);
        break;
       case DW_ATE_float:
-       type = dwarf2_init_float_type (objfile, bits, name, name);
+       type = dwarf2_init_float_type (objfile, bits, name, name, byte_order);
        break;
       case DW_ATE_signed:
        type = dwarf2_init_integer_type (cu, objfile, bits, 0, name);
@@ -17827,17 +17846,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
 
   maybe_set_alignment (cu, die, type);
 
-  switch (endianity)
-    {
-      case DW_END_big:
-        if (gdbarch_byte_order (arch) == BFD_ENDIAN_LITTLE)
-          TYPE_ENDIANITY_NOT_DEFAULT (type) = 1;
-        break;
-      case DW_END_little:
-        if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
-          TYPE_ENDIANITY_NOT_DEFAULT (type) = 1;
-        break;
-    }
+  TYPE_ENDIANITY_NOT_DEFAULT (type) = gdbarch_byte_order (arch) != byte_order;
 
   return set_die_type (die, type, cu);
 }
@@ -21773,7 +21782,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       OBJSTAT (objfile, n_syms++);
 
       /* Cache this symbol's name and the name's demangled form (if any).  */
-      SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
+      sym->set_language (cu->language, &objfile->objfile_obstack);
       linkagename = dwarf2_physname (name, die, cu);
       SYMBOL_SET_NAMES (sym, linkagename, false, objfile);
 
This page took 0.03223 seconds and 4 git commands to generate.