CSKY: Change ISA flag's type to bfd_uint64_t and fix build error.
[deliverable/binutils-gdb.git] / gas / symbols.c
index 50b23d6ded66cfcf11f9d4d3c5747f9752ee4d73..d6080886be8b27000d03621310776fd35e570762 100644 (file)
 #include "subsegs.h"
 #include "write.h"
 
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
 struct symbol_flags
 {
   /* Whether the symbol is a local_symbol.  */
@@ -382,7 +389,8 @@ local_symbol_convert (void *sym)
 
   ++local_symbol_conversion_count;
 
-  xtra = (struct xsymbol *) obstack_alloc (&notes, sizeof *xtra);
+  xtra = (struct xsymbol *) obstack_alloc (&notes, sizeof (*xtra));
+  memset (xtra, 0, sizeof (*xtra));
   val = ent->lsy.value;
   ent->sy.x = xtra;
 
@@ -1558,14 +1566,24 @@ resolve_symbol_value (symbolS *symp)
 
              right = 1;
            }
+         if ((op == O_left_shift || op == O_right_shift)
+             && (valueT) right >= sizeof (valueT) * CHAR_BIT)
+           {
+             as_warn_value_out_of_range (_("shift count"), right, 0,
+                                         sizeof (valueT) * CHAR_BIT - 1,
+                                         NULL, 0);
+             left = right = 0;
+           }
 
          switch (symp->x->value.X_op)
            {
            case O_multiply:            left *= right; break;
            case O_divide:              left /= right; break;
            case O_modulus:             left %= right; break;
-           case O_left_shift:          left <<= right; break;
-           case O_right_shift:         left >>= right; break;
+           case O_left_shift:
+             left = (valueT) left << (valueT) right; break;
+           case O_right_shift:
+             left = (valueT) left >> (valueT) right; break;
            case O_bit_inclusive_or:    left |= right; break;
            case O_bit_or_not:          left |= ~right; break;
            case O_bit_exclusive_or:    left ^= right; break;
@@ -1760,8 +1778,8 @@ snapshot_symbol (symbolS **symbolPP, valueT *valueP, segT *segP, fragS **fragPP)
 static long *dollar_labels;
 static long *dollar_label_instances;
 static char *dollar_label_defines;
-static unsigned long dollar_label_count;
-static unsigned long dollar_label_max;
+static size_t dollar_label_count;
+static size_t dollar_label_max;
 
 int
 dollar_label_defined (long label)
@@ -1797,7 +1815,8 @@ dollar_label_instance (long label)
 void
 dollar_label_clear (void)
 {
-  memset (dollar_label_defines, '\0', (unsigned int) dollar_label_count);
+  if (dollar_label_count)
+    memset (dollar_label_defines, '\0', dollar_label_count);
 }
 
 #define DOLLAR_LABEL_BUMP_BY 10
This page took 0.0233139999999999 seconds and 4 git commands to generate.