gas/
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 26 Apr 2005 17:15:22 +0000 (17:15 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 26 Apr 2005 17:15:22 +0000 (17:15 +0000)
2005-04-26  H.J. Lu  <hongjiu.lu@intel.com>

* config/obj-multi.h (FAKE_LABEL_NAME): Defined.

* read.c (pseudo_set): Disallow symbol set to common symbol.

PR 857
* write.c (write_object_file): Report common symbol name when
disallowing local symbol set to common symbol.
(adjust_reloc_syms): Disallow local symbol set to undefined
symbol.

gas/testsuite/

2005-04-26  H.J. Lu  <hongjiu.lu@intel.com>

* gas/all/assign.s: Make `x' and `y' global.

gas/ChangeLog
gas/config/obj-multi.h
gas/read.c
gas/testsuite/ChangeLog
gas/testsuite/gas/all/assign.s
gas/write.c

index 3f06e7a6c464718442d2388684a7cff674c055dd..28cf35e7a8c89b9e4281b9b8baef0a291ac8fedf 100644 (file)
@@ -1,3 +1,15 @@
+2005-04-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config/obj-multi.h (FAKE_LABEL_NAME): Defined.
+
+       * read.c (pseudo_set): Disallow symbol set to common symbol.
+
+       PR 857
+       * write.c (write_object_file): Report common symbol name when
+       disallowing local symbol set to common symbol.
+       (adjust_reloc_syms): Disallow local symbol set to undefined
+       symbol.
+
 2005-04-25  Jan Beulich  <jbeulich@novell.com>
 
        * macro.c (macro_expand_body): Replace locals indicator parameters
index 0e1190b87e591fca6b0cc2152f47bc43d0e3ed1e..2cca674e15bd5f5f2260a7f842e5e78200e721e4 100644 (file)
 
 #define EMIT_SECTION_SYMBOLS (this_format->emit_section_symbols)
 
+#define FAKE_LABEL_NAME (this_emulation->fake_label_name)
+
 #ifdef OBJ_MAYBE_ELF
 /* We need OBJ_SYMFIELD_TYPE so that symbol_get_obj is defined in symbol.c
    We also need various STAB defines for stab.c  */
index b83f14017f56091fcf3a650e6e04441f5a66592a..54ac84486374b8fa3e8ba54a7ed488fc74a41f32 100644 (file)
@@ -3301,6 +3301,10 @@ pseudo_set (symbolS *symbolP)
        {
          symbolS *s = exp.X_add_symbol;
 
+         if (S_IS_COMMON (s))
+           as_bad (_("`%s' can't be equated to common symbol '%s'"),
+                   S_GET_NAME (symbolP), S_GET_NAME (s));
+
          S_SET_SEGMENT (symbolP, seg);
          S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (s));
          symbol_set_frag (symbolP, symbol_get_frag (s));
index 887cd03efc7baefe41381c078d4d2428c470d3f8..2504e0cad4e76dd747b9baa2ac9f23ea0a47f865 100644 (file)
@@ -1,3 +1,7 @@
+2005-04-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * gas/all/assign.s: Make `x' and `y' global.
+
 2005-04-25  Jan Beulich  <jbeulich@novell.com>
 
        * gas/macros/badarg.s: Add tests for collisions between/among macro
index 1a414066f69f0c3a4da761e944184bdb41620d14..5f94392dc9ac51343b4648b7008f4aab681b25a0 100644 (file)
@@ -1,7 +1,9 @@
+ .global x
  x = zzz
  x = x+1
  .long x
 
+ .global y
  y = 1
  y = y+zzz
  .long y
index e154cda427740fd6b6a19b96ff2b2ef50ff71f7c..417e0e971ea970bac8795dc5a52438b56e2397ca 100644 (file)
@@ -787,12 +787,20 @@ adjust_reloc_syms (bfd *abfd ATTRIBUTE_UNUSED,
        if (fixp->fx_subsy != NULL)
          resolve_symbol_value (fixp->fx_subsy);
 
-       /* If this symbol is equated to an undefined symbol, convert
-           the fixup to being against that symbol.  */
+       /* If this symbol is equated to an undefined or common symbol,
+          convert the fixup to being against that symbol.  */
        if (symbol_equated_reloc_p (sym))
          {
+           symbolS *new_sym
+             = symbol_get_value_expression (sym)->X_add_symbol;
+           const char *name = S_GET_NAME (sym);
+           if (!S_IS_COMMON (new_sym)
+               && strcmp (name, FAKE_LABEL_NAME)
+               && (!S_IS_EXTERNAL (sym) || S_IS_LOCAL (sym)))
+             as_bad (_("Local symbol `%s' can't be equated to undefined symbol `%s'"),
+                     name, S_GET_NAME (new_sym));
            fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
-           sym = symbol_get_value_expression (sym)->X_add_symbol;
+           sym = new_sym;
            fixp->fx_addsy = sym;
          }
 
@@ -1927,9 +1935,15 @@ write_object_file (void)
              symbols.  */
          if (symbol_equated_reloc_p (symp))
            {
-             if (S_IS_COMMON (symp))
-               as_bad (_("`%s' can't be equated to common symbol"),
-                       S_GET_NAME (symp));
+             const char *name = S_GET_NAME (symp);
+             if (S_IS_COMMON (symp)
+                 && strcmp (name, FAKE_LABEL_NAME)
+                 && (!S_IS_EXTERNAL (symp) || S_IS_LOCAL (symp)))
+               {
+                 expressionS *e = symbol_get_value_expression (symp);
+                 as_bad (_("Local symbol `%s' can't be equated to common symbol `%s'"),
+                         name, S_GET_NAME (e->X_add_symbol));
+               }
              symbol_remove (symp, &symbol_rootP, &symbol_lastP);
              continue;
            }