Add code to retry certain open()s.
[deliverable/binutils-gdb.git] / gas / symbols.c
index a9dac42f3166463c5a398ce58fcef42c7ba3247c..98623eb7005c9ca8af60e817250be232a81069e2 100644 (file)
@@ -1,5 +1,6 @@
 /* symbols.c -symbol table-
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -55,6 +56,9 @@ symbolS abs_symbol;
 #define debug_verify_symchain(root, last) ((void) 0)
 #endif
 
+#define DOLLAR_LABEL_CHAR      '\001'
+#define LOCAL_LABEL_CHAR       '\002'
+
 struct obstack notes;
 
 static void fb_label_init PARAMS ((void));
@@ -251,6 +255,10 @@ local_symbol_convert (locsym)
   /* Local symbols are always either defined or used.  */
   ret->sy_used = 1;
 
+#ifdef TC_LOCAL_SYMFIELD_CONVERT
+  TC_LOCAL_SYMFIELD_CONVERT (locsym, ret);
+#endif
+
   symbol_table_insert (ret);
 
   local_symbol_mark_converted (locsym);
@@ -436,7 +444,7 @@ colon (sym_name)            /* Just seen "x:" - rattle symbols & frags.  */
                            S_GET_OTHER (symbolP),
                            S_GET_DESC (symbolP));
 #endif
-                 as_fatal (_("Symbol \"%s\" is already defined as \"%s\"/%s%ld."),
+                 as_bad (_("Symbol \"%s\" is already defined as \"%s\"/%s%ld."),
                            sym_name,
                            segment_name (S_GET_SEGMENT (symbolP)),
                            od_buf,
@@ -450,8 +458,8 @@ colon (sym_name)            /* Just seen "x:" - rattle symbols & frags.  */
          if (!(frag_now == symbolP->sy_frag
                && S_GET_VALUE (symbolP) == frag_now_fix ()
                && S_GET_SEGMENT (symbolP) == now_seg))
-           as_fatal (_("Symbol %s already defined."), sym_name);
-       }                       /* if this symbol is not yet defined  */
+           as_bad (_("Symbol %s already defined."), sym_name);
+       }
 
     }
 #ifdef BFD_ASSEMBLER
@@ -471,7 +479,7 @@ colon (sym_name)            /* Just seen "x:" - rattle symbols & frags.  */
 #endif /* OBJ_VMS */
 
       symbol_table_insert (symbolP);
-    }                          /* if we have seen this symbol before  */
+    }
 
   if (mri_common_symbol != NULL)
     {
@@ -862,6 +870,10 @@ resolve_symbol_value (symp, finalize)
 
   resolved = 0;
   final_seg = S_GET_SEGMENT (symp);
+  /* Expressions aren't really symbols, so don't finalize their values
+     until relaxation is complete.  */
+  if (final_seg == expr_section && finalize != 2)
+    finalize = 0;
 
   if (symp->sy_resolving)
     {
@@ -1178,7 +1190,7 @@ resolve_local_symbol (key, value)
      PTR value;
 {
   if (value != NULL)
-    resolve_symbol_value (value, 1);
+    resolve_symbol_value (value, finalize_syms);
 }
 
 #endif
@@ -1329,7 +1341,7 @@ dollar_label_name (n, augend)
   while ((*p = *--q) != '\0')
     ++p;
 
-  *p++ = 1;                    /* ^A  */
+  *p++ = DOLLAR_LABEL_CHAR;            /* ^A  */
 
   /* Instance number.  */
   q = symbol_name_temporary;
@@ -1483,6 +1495,9 @@ fb_label_name (n, augend)
   know (n >= 0);
   know (augend == 0 || augend == 1);
   p = symbol_name_build;
+#ifdef LOCAL_LABEL_PREFIX
+  *p++ = LOCAL_LABEL_PREFIX;
+#endif
   *p++ = 'L';
 
   /* Next code just does sprintf( {}, "%d", n);  */
@@ -1496,7 +1511,7 @@ fb_label_name (n, augend)
   while ((*p = *--q) != '\0')
     ++p;
 
-  *p++ = 2;                    /* ^B  */
+  *p++ = LOCAL_LABEL_CHAR;             /* ^B  */
 
   /* Instance number.  */
   q = symbol_name_temporary;
@@ -1524,17 +1539,23 @@ decode_local_label_name (s)
   int label_number;
   int instance_number;
   char *type;
-  const char *message_format = _("\"%d\" (instance number %d of a %s label)");
+  const char *message_format;
+  int index = 0;
+
+#ifdef LOCAL_LABEL_PREFIX
+  if (s[index] == LOCAL_LABEL_PREFIX)
+    ++index;
+#endif
 
-  if (s[0] != 'L')
+  if (s[index] != 'L')
     return s;
 
-  for (label_number = 0, p = s + 1; isdigit ((unsigned char) *p); ++p)
+  for (label_number = 0, p = s + index + 1; isdigit ((unsigned char) *p); ++p)
     label_number = (10 * label_number) + *p - '0';
 
-  if (*p == 1)
+  if (*p == DOLLAR_LABEL_CHAR)
     type = "dollar";
-  else if (*p == 2)
+  else if (*p == LOCAL_LABEL_CHAR)
     type = "fb";
   else
     return s;
@@ -1542,6 +1563,7 @@ decode_local_label_name (s)
   for (instance_number = 0, p++; isdigit ((unsigned char) *p); ++p)
     instance_number = (10 * instance_number) + *p - '0';
 
+  message_format = _("\"%d\" (instance number %d of a %s label)");
   symbol_decode = obstack_alloc (&notes, strlen (message_format) + 30);
   sprintf (symbol_decode, message_format, label_number, instance_number, type);
 
@@ -1560,7 +1582,11 @@ S_GET_VALUE (s)
 #endif
 
   if (!s->sy_resolved && s->sy_value.X_op != O_constant)
-    resolve_symbol_value (s, 1);
+    {
+      valueT val = resolve_symbol_value (s, finalize_syms);
+      if (finalize_syms != 2 && S_GET_SEGMENT (s) == expr_section)
+       return val;
+    }
   if (s->sy_value.X_op != O_constant)
     {
       static symbolS *recur;
@@ -1721,8 +1747,8 @@ S_IS_LOCAL (s)
   name = S_GET_NAME (s);
   return (name != NULL
          && ! S_IS_DEBUG (s)
-         && (strchr (name, '\001')
-             || strchr (name, '\002')
+         && (strchr (name, DOLLAR_LABEL_CHAR)
+             || strchr (name, LOCAL_LABEL_CHAR)
              || (! flag_keep_locals
                  && (bfd_is_local_label (stdoutput, s->bsym)
                      || (flag_mri
This page took 0.035815 seconds and 4 git commands to generate.