* config/tc-ppc.c (md_section_align): Don't round up address for ELF.
[deliverable/binutils-gdb.git] / gas / symbols.c
index 0110f4204d9bfdf219aaa7c0d33062644c111f8b..117d1220e670fb81fe088271be387976a388b910 100644 (file)
@@ -332,8 +332,16 @@ colon (/* Just seen "x:" - rattle symbols & frags.  */
          local_symbol_set_frag (locsym, frag_now);
          locsym->lsy_value = frag_now_fix ();
        }
-      else if (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))
+      else if (!(S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
+              || S_IS_COMMON (symbolP)
+              || S_IS_VOLATILE (symbolP))
        {
+         if (S_IS_VOLATILE (symbolP))
+           {
+             symbolP = symbol_clone (symbolP, 1);
+             S_SET_VALUE (symbolP, 0);
+             S_CLEAR_VOLATILE (symbolP);
+           }
          if (S_GET_VALUE (symbolP) == 0)
            {
              symbolP->sy_frag = frag_now;
@@ -365,6 +373,7 @@ colon (/* Just seen "x:" - rattle symbols & frags.  */
                    && S_IS_EXTERNAL (symbolP))
                   || S_GET_SEGMENT (symbolP) == bss_section)
                  && (now_seg == data_section
+                     || now_seg == bss_section
                      || now_seg == S_GET_SEGMENT (symbolP)))
                {
                  /* Select which of the 2 cases this is.  */
@@ -420,7 +429,10 @@ colon (/* 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_bad (_("symbol `%s' is already defined"), sym_name);
+           {
+             as_bad (_("symbol `%s' is already defined"), sym_name);
+             symbolP = symbol_clone (symbolP, 0);
+           }
        }
 
     }
@@ -542,6 +554,7 @@ symbolS *
 symbol_clone (symbolS *orgsymP, int replace)
 {
   symbolS *newsymP;
+  asymbol *bsymorg, *bsymnew;
 
   /* Running local_symbol_convert on a clone that's not the one currently
      in local_hash would incorrectly replace the hash entry.  Thus the
@@ -549,11 +562,30 @@ symbol_clone (symbolS *orgsymP, int replace)
      depends on not encountering an unconverted symbol.  */
   if (LOCAL_SYMBOL_CHECK (orgsymP))
     orgsymP = local_symbol_convert ((struct local_symbol *) orgsymP);
+  bsymorg = orgsymP->bsym;
 
   know (S_IS_DEFINED (orgsymP));
 
   newsymP = obstack_alloc (&notes, sizeof (*newsymP));
   *newsymP = *orgsymP;
+  bsymnew = bfd_make_empty_symbol (bfd_asymbol_bfd (bsymorg));
+  if (bsymnew == NULL)
+    as_perror ("%s", "bfd_make_empty_symbol");
+  newsymP->bsym = bsymnew;
+  bsymnew->name = bsymorg->name;
+  bsymnew->flags =  bsymorg->flags;
+  bsymnew->section =  bsymorg->section;
+  bsymnew->udata.p = (PTR) newsymP;
+  bfd_copy_private_symbol_data (bfd_asymbol_bfd (bsymorg), bsymorg,
+                               bfd_asymbol_bfd (bsymnew), bsymnew);
+
+#ifdef obj_symbol_clone_hook
+  obj_symbol_clone_hook (newsymP, orgsymP);
+#endif
+
+#ifdef tc_symbol_clone_hook
+  tc_symbol_clone_hook (newsymP, orgsymP);
+#endif
 
   if (replace)
     {
@@ -893,13 +925,11 @@ report_op_error (symbolS *symp, symbolS *left, symbolS *right)
          && seg_right != undefined_section)
        {
          if (right)
-           as_bad_where (file, line,
-                         _("invalid sections for operation on `%s' and `%s' setting `%s'"),
-                         S_GET_NAME (left), S_GET_NAME (right), S_GET_NAME (symp));
+           as_bad (_("invalid sections for operation on `%s' and `%s' setting `%s'"),
+                   S_GET_NAME (left), S_GET_NAME (right), S_GET_NAME (symp));
          else
-           as_bad_where (file, line,
-                         _("invalid section for operation on `%s' setting `%s'"),
-                         S_GET_NAME (left), S_GET_NAME (symp));
+           as_bad (_("invalid section for operation on `%s' setting `%s'"),
+                   S_GET_NAME (left), S_GET_NAME (symp));
        }
     }
 }
@@ -1320,8 +1350,10 @@ resolve_local_symbol_values (void)
    sub-expressions used.  */
 
 int
-snapshot_symbol (symbolS *symbolP, valueT *valueP, segT *segP, fragS **fragPP)
+snapshot_symbol (symbolS **symbolPP, valueT *valueP, segT *segP, fragS **fragPP)
 {
+  symbolS *symbolP = *symbolPP;
+
   if (LOCAL_SYMBOL_CHECK (symbolP))
     {
       struct local_symbol *locsym = (struct local_symbol *) symbolP;
@@ -1350,10 +1382,7 @@ snapshot_symbol (symbolS *symbolP, valueT *valueP, segT *segP, fragS **fragPP)
            {
            case O_constant:
            case O_register:
-             /* This check wouldn't be needed if pseudo_set() didn't set
-                symbols equated to bare symbols to undefined_section.  */
-             if (symbolP->bsym->section != undefined_section
-                 || symbolP->sy_value.X_op != O_symbol)
+             if (!symbol_equated_p (symbolP))
                break;
              /* Fall thru.  */
            case O_symbol:
@@ -1365,6 +1394,10 @@ snapshot_symbol (symbolS *symbolP, valueT *valueP, segT *segP, fragS **fragPP)
            }
        }
 
+      /* Never change a defined symbol.  */
+      if (symbolP->bsym->section == undefined_section
+         || symbolP->bsym->section == expr_section)
+       *symbolPP = symbolP;
       *valueP = expr.X_add_number;
       *segP = symbolP->bsym->section;
       *fragPP = symbolP->sy_frag;
@@ -1761,20 +1794,11 @@ S_GET_VALUE (symbolS *s)
 
   if (s->sy_value.X_op != O_constant)
     {
-      static symbolS *recur;
-
-      /* FIXME: In non BFD assemblers, S_IS_DEFINED and S_IS_COMMON
-        may call S_GET_VALUE.  We use a static symbol to avoid the
-        immediate recursion.  */
-      if (recur == s)
-       return (valueT) s->sy_value.X_add_number;
-      recur = s;
       if (! s->sy_resolved
          || s->sy_value.X_op != O_symbol
          || (S_IS_DEFINED (s) && ! S_IS_COMMON (s)))
        as_bad (_("attempt to get value of unresolved symbol `%s'"),
                S_GET_NAME (s));
-      recur = NULL;
     }
   return (valueT) s->sy_value.X_add_number;
 }
@@ -2174,6 +2198,13 @@ S_SET_VOLATILE (symbolS *s)
   s->sy_volatile = 1;
 }
 
+void
+S_CLEAR_VOLATILE (symbolS *s)
+{
+  if (!LOCAL_SYMBOL_CHECK (s))
+    s->sy_volatile = 0;
+}
+
 void
 S_SET_FORWARD_REF (symbolS *s)
 {
This page took 0.026791 seconds and 4 git commands to generate.