gas/
authorJan Beulich <jbeulich@novell.com>
Thu, 17 Nov 2005 07:29:28 +0000 (07:29 +0000)
committerJan Beulich <jbeulich@novell.com>
Thu, 17 Nov 2005 07:29:28 +0000 (07:29 +0000)
2005-11-17  Jan Beulich  <jbeulich@novell.com>

* symbols.h (S_CLEAR_VOLATILE): Declare.
* symbols.c (colon): Also accept redefinable symbols for
redefinition. Clone them before modifying.
(S_CLEAR_VOLATILE): Define.
* cond.c (s_ifdef): Also test for equated symbols.
* read.c (s_comm_internal): Also exclude non-redefinable
equated symbols. Clone redefinable ones before modifying.
(s_weakref): Clone redefinable symbols before modifying.
* doc/internals.texi: Document sy_volatile, sy_forward_ref,
S_IS_VOLATILE, S_SET_VOLATILE, S_CLEAR_VOLATILE,
S_IS_FORWARD_REF, and S_SET_FORWARD_REF.

gas/testsuite/
2005-11-17  Jan Beulich  <jbeulich@novell.com>

* gas/all/cond.s: Also check ifdef works on equates and
commons.
* gas/all/cond.l: Adjust.
* gas/all/redef2.s: Also test redefining equate to label.
* gas/all/redef2.d: Adjust.
* gas/all/redef3.[sd]: New.
* gas/all/redef4.s: New.
* gas/all/redef5.s: New.
* gas/elf/redef.s: New, copied from original gas/all/redef2.s.
* gas/elf/redef.d: Remove #source.
* gas/all/gas.exp: Remove exclusion of iq2000-*-* from and
adjust xfails for redefinition tests. Run new tests. Exclude
alpha*-*-*, mips*-*-*, *c54x*-*-* from weakref tests.

18 files changed:
gas/ChangeLog
gas/cond.c
gas/doc/internals.texi
gas/read.c
gas/symbols.c
gas/symbols.h
gas/testsuite/ChangeLog
gas/testsuite/gas/all/cond.l
gas/testsuite/gas/all/cond.s
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/all/redef2.d
gas/testsuite/gas/all/redef2.s
gas/testsuite/gas/all/redef3.d [new file with mode: 0644]
gas/testsuite/gas/all/redef3.s [new file with mode: 0644]
gas/testsuite/gas/all/redef4.s [new file with mode: 0644]
gas/testsuite/gas/all/redef5.s [new file with mode: 0644]
gas/testsuite/gas/elf/redef.d
gas/testsuite/gas/elf/redef.s [new file with mode: 0644]

index 6dc58086de6dd0635566917dfdb1d5e94bc2f05a..531391959fdaf4319e0473044149fe182c3d0f88 100644 (file)
@@ -1,3 +1,18 @@
+2005-11-17  Jan Beulich  <jbeulich@novell.com>
+
+
+       * symbols.h (S_CLEAR_VOLATILE): Declare.
+       * symbols.c (colon): Also accept redefinable symbols for
+       redefinition. Clone them before modifying.
+       (S_CLEAR_VOLATILE): Define.
+       * cond.c (s_ifdef): Also test for equated symbols.
+       * read.c (s_comm_internal): Also exclude non-redefinable
+       equated symbols. Clone redefinable ones before modifying.
+       (s_weakref): Clone redefinable symbols before modifying.
+       * doc/internals.texi: Document sy_volatile, sy_forward_ref,
+       S_IS_VOLATILE, S_SET_VOLATILE, S_CLEAR_VOLATILE,
+       S_IS_FORWARD_REF, and S_SET_FORWARD_REF.
+
 2005-11-16  Alan Modra  <amodra@bigpond.net.au>
 
        * config/tc-hppa.c (pa_comm): Set bfd_com_section segment.
index e791b11881a97cce7e5f545c52ada681881dfce3..d6c32acc2532f5de48f65f15fb06b2a1cb60cef2 100644 (file)
@@ -102,7 +102,7 @@ s_ifdef (int test_defined)
         considered to be undefined.  */
       is_defined =
        symbolP != NULL
-       && S_IS_DEFINED (symbolP)
+       && (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
        && S_GET_SEGMENT (symbolP) != reg_section;
 
       cframe.ignoring = ! (test_defined ^ is_defined);
index 51b4061030f24382a417d70587fb280a6a2144ff..dffdb1e04fa99a68430e7a6253278c362147fc9b 100644 (file)
@@ -93,6 +93,12 @@ responsible for setting it when a symbol is used in backend routines.
 Whether the symbol is an MRI common symbol created by the @code{COMMON}
 pseudo-op when assembling in MRI mode.
 
+@item sy_volatile
+Whether the symbol can be re-defined.
+
+@item sy_forward_ref
+Whether the symbol's value must only be evaluated upon use.
+
 @item sy_weakrefr
 Whether the symbol is a @code{weakref} alias to another symbol.
 
@@ -165,6 +171,16 @@ Return non-zero if the symbol is a @code{weakref} alias.
 Return non-zero if the symbol was aliased by a @code{weakref} alias and has not
 had any strong references.
 
+@item S_IS_VOLATILE
+@cindex S_IS_VOLATILE
+Return non-zero if the symbol may be re-defined. Such symbols get created by
+the @code{=} operator, @code{equ}, or @code{set}.
+
+@item S_IS_FORWARD_REF
+@cindex S_IS_FORWARD_REF
+Return non-zero if the symbol is a forward reference, that is its value must
+only be determined upon use.
+
 @item S_IS_COMMON
 @cindex S_IS_COMMON
 Return non-zero if this is a common symbol.  Common symbols are sometimes
@@ -222,6 +238,19 @@ Clear the @code{weakref} aliased status of a symbol.  This is implicitly called
 whenever the symbol is looked up, as part of a direct reference or a
 definition, but not as part of a @code{weakref} directive.
 
+@item S_SET_VOLATILE
+@cindex S_SET_VOLATILE
+Indicate that the symbol may be re-defined.
+
+@item S_CLEAR_VOLATILE
+@cindex S_CLEAR_VOLATILE
+Indicate that the symbol may no longer be re-defined.
+
+@item S_SET_FORWARD_REF
+@cindex S_SET_FORWARD_REF
+Indicate that the symbol is a forward reference, that is its value must only
+be determined upon use.
+
 @item S_GET_TYPE
 @item S_GET_DESC
 @item S_GET_OTHER
index 84ca9fa47cad70f2dd1e748788e48596be085cb0..0485d72dec6726986e4315c853a1859c2fda6e98 100644 (file)
@@ -1467,13 +1467,25 @@ s_comm_internal (int param,
 
   *p = 0;
   symbolP = symbol_find_or_make (name);
-  if (S_IS_DEFINED (symbolP) && !S_IS_COMMON (symbolP))
+  if ((S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
+      && !S_IS_COMMON (symbolP))
     {
-      symbolP = NULL;
-      as_bad (_("symbol `%s' is already defined"), name);
-      *p = c;
-      ignore_rest_of_line ();
-      goto out;
+      if (!S_IS_VOLATILE (symbolP))
+       {
+         symbolP = NULL;
+         as_bad (_("symbol `%s' is already defined"), name);
+         *p = c;
+         ignore_rest_of_line ();
+         goto out;
+       }
+      /* This could be avoided when the symbol wasn't used so far, but
+        the comment in struc-symbol.h says this flag isn't reliable.  */
+      if (1 || !symbol_used_p (symbolP))
+       symbolP = symbol_clone (symbolP, 1);
+      S_SET_SEGMENT (symbolP, undefined_section);
+      S_SET_VALUE (symbolP, 0);
+      symbol_set_frag (symbolP, &zero_address_frag);
+      S_CLEAR_VOLATILE (symbolP);
     }
 
   size = S_GET_VALUE (symbolP);
@@ -3174,10 +3186,18 @@ s_weakref (int ignore ATTRIBUTE_UNUSED)
 
   if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
     {
-      as_bad (_("symbol `%s' is already defined"), name);
-      *end_name = delim;
-      ignore_rest_of_line ();
-      return;
+      if(!S_IS_VOLATILE (symbolP))
+       {
+         as_bad (_("symbol `%s' is already defined"), name);
+         *end_name = delim;
+         ignore_rest_of_line ();
+         return;
+       }
+      /* This could be avoided when the symbol wasn't used so far, but
+        the comment in struc-symbol.h says this flag isn't reliable.  */
+      if (1 || !symbol_used_p (symbolP))
+       symbolP = symbol_clone (symbolP, 1);
+      S_CLEAR_VOLATILE (symbolP);
     }
 
   *end_name = delim;
index f781a3574bf93d7528f878bcc6336605e8e34776..f6dafcd86b239ea4471486ec6e8325c0bfe65152 100644 (file)
@@ -333,8 +333,18 @@ colon (/* Just seen "x:" - rattle symbols & frags.  */
          locsym->lsy_value = frag_now_fix ();
        }
       else if (!(S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
-              || S_IS_COMMON (symbolP))
+              || S_IS_COMMON (symbolP)
+              || S_IS_VOLATILE (symbolP))
        {
+         if (S_IS_VOLATILE (symbolP)
+             /* This could be avoided when the symbol wasn't used so far, but
+                the comment in struc-symbol.h says this flag isn't reliable.  */
+             && (1 || !symbol_used_p (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;
@@ -421,7 +431,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);
+           }
        }
 
     }
@@ -2186,6 +2199,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)
 {
index 99fa3c3c47df674a5b62c1ff30695a563434500a..d4e56fb9967aa4989b0caeabc6b5146b5a95ff9d 100644 (file)
@@ -108,6 +108,7 @@ extern void S_SET_WEAKREFD (symbolS *);
 extern void S_CLEAR_WEAKREFD (symbolS *);
 extern void S_SET_THREAD_LOCAL (symbolS *);
 extern void S_SET_VOLATILE (symbolS *);
+extern void S_CLEAR_VOLATILE (symbolS *);
 extern void S_SET_FORWARD_REF (symbolS *);
 
 #ifndef WORKING_DOT_WORD
index 059cc50b90d41bfaec459501e013f7c9b8c7a006..dafe7047ed299ae306f84353c545ef28a064ef81 100644 (file)
@@ -1,3 +1,19 @@
+2005-11-17  Jan Beulich  <jbeulich@novell.com>
+
+       * gas/all/cond.s: Also check ifdef works on equates and
+       commons.
+       * gas/all/cond.l: Adjust.
+       * gas/all/redef2.s: Also test redefining equate to label.
+       * gas/all/redef2.d: Adjust.
+       * gas/all/redef3.[sd]: New.
+       * gas/all/redef4.s: New.
+       * gas/all/redef5.s: New.
+       * gas/elf/redef.s: New, copied from original gas/all/redef2.s.
+       * gas/elf/redef.d: Remove #source.
+       * gas/all/gas.exp: Remove exclusion of iq2000-*-* from and
+       adjust xfails for redefinition tests. Run new tests. Exclude
+       alpha*-*-*, mips*-*-*, *c54x*-*-* from weakref tests.
+
 2005-11-16  Richard Henderson  <rth@redhat.com>
 
        * gas/all/weakref1.s: Use "=" instead of ".set" for equivalence.
index a103d8dae70e66cb7cb61906342a6a08177179e7..6939ee85080a3abef6a1646e4b07963580ecec22 100644 (file)
   29[  ]+.else
   31[  ]+.endif
 [      ]*[1-9][0-9]*[  ]+
+[      ]*[1-9][0-9]*[  ]+\.comm[       ]+c,[   ]*1[    ]*
+[      ]*[1-9][0-9]*[  ]+\.ifndef[     ]+c[    ]*
+[      ]*[1-9][0-9]*[  ]+\.endif[      ]*
+[      ]*[1-9][0-9]*[  ]+
 [      ]*[1-9][0-9]*[  ]+\.equiv[      ]+x,[   ]*y[    ]*
+[      ]*[1-9][0-9]*[  ]+\.ifndef[     ]+x[    ]*
+[      ]*[1-9][0-9]*[  ]+\.endif[      ]*
 [      ]*[1-9][0-9]*[  ]+\.equiv[      ]+y,[   ]*0[    ]*
 [      ]*[1-9][0-9]*[  ]+\.if[         ]+x[    ]*
 [      ]*[1-9][0-9]*[  ]+\.elseif[     ]+x[    ]*
index 2737d1ff298ae8c6a002d4c8a1324d102d367258..94136acb2373162db808bbfec99c191e675ef864 100644 (file)
        .long   9
        .endif
 
+       .comm   c, 1
+       .ifndef c
+       .err
+       .endif
+
        .equiv  x, y
+       .ifndef x
+       .err
+       .endif
        .equiv  y, 0
        .if     x
        .err
index d92ede8450e7ea97c32ea5198388bb37567e1188..c97a7301a1de83a5481fcf6fd6aaf09f74be828f 100644 (file)
@@ -74,16 +74,24 @@ case $target_triplet in {
 # .set works differently on some targets.
 case $target_triplet in {
     { alpha*-*-* } { }
-    { iq2000*-*-* } { }
     { mips*-*-* } { }
     { *c54x*-*-* } { }
     { z80-*-* } { }
     default {
        setup_xfail "*c30*-*-*" "*c4x*-*-*" "pdp11-*-*"
        run_dump_test redef
-       setup_xfail "*c30*-*-*" "*c4x*-*-*" "*arm*-*-coff" "arm*-*-pe*" "crx*-*-*"
-       setup_xfail "h8300*-*-*" "m68hc*-*-*" "maxq-*-*" "pdp11-*-*" "vax*-*-*" "z8k-*-*"
+       setup_xfail "*c30*-*-*" "*c4x*-*-*" "*arm*-*-*aout*" "*arm*-*-*coff" \
+           "*arm*-*-pe" "crx*-*-*" "h8300*-*-*" "m68hc*-*-*" "maxq-*-*" \
+           "pdp11-*-*" "vax*-*-*" "z8k-*-*"
        run_dump_test redef2
+       setup_xfail "*-*-aix*" "*-*-coff" "*-*-cygwin" "*-*-mingw*" "*-*-pe*" \
+           "bfin-*-*" "*c4x*-*-*" "crx*-*-*" "h8300*-*-*" "m68hc*-*-*" \
+           "maxq-*-*" "or32-*-*" "pdp11-*-*" "vax*-*-*" "z8k-*-*"
+       run_dump_test redef3
+       setup_xfail "*c4x*-*-*"
+       gas_test_error "redef4.s" "" ".set for symbol already used as label"
+       setup_xfail "*c4x*-*-*"
+       gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
     }
 }
 
@@ -256,6 +264,9 @@ if { ![istarget "i960-*-*"] } {
 
 # .set works differently on some targets.
 case $target_triplet in {
+    { alpha*-*-* } { }
+    { mips*-*-* } { }
+    { *c54x*-*-* } { }
     { z80-*-* } { }
     default {
        run_dump_test weakref1
index 452d610beb2ebbc250cf750e4cfa2a184e0b6c32..d53efa5e0ecdf13fccafe6605c41b43f4d0ad47d 100644 (file)
@@ -5,9 +5,11 @@
 
 RELOCATION RECORDS FOR .*
 .*
-0+0.*(here|\.data)
-0+8.*xtrn
+0+00.*(here|\.data)
+0+08.*xtrn
+0+10.*(sym|\.data(\+0x0+10)?)
 #...
 Contents of section \.data:
  0000 00000000 11111111 00000000 22222222[     ]+................[     ]*
+ 0010 [01]00000[01]0 .*
 #pass
index 3e975e137280d9dd0cb7f7f44a032875c1d3674f..89a29ac13842648635ee83d9e35f0d491812f3ec 100644 (file)
@@ -8,3 +8,5 @@ here:
  .long sym
  .set sym, 0x22222222
  .long sym
+sym:
+ .long sym
diff --git a/gas/testsuite/gas/all/redef3.d b/gas/testsuite/gas/all/redef3.d
new file mode 100644 (file)
index 0000000..85843bb
--- /dev/null
@@ -0,0 +1,15 @@
+#objdump: -rsj .data
+#name: .equ redefinitions (3)
+
+.*: .*
+
+RELOCATION RECORDS FOR .*
+.*
+0+00.*(here|\.data)
+0+08.*xtrn
+0+10.*sym
+#...
+Contents of section \.data:
+ 0000 00000000 11111111 00000000 22222222[     ]+................[     ]*
+ 0010 00000000 .*
+#pass
diff --git a/gas/testsuite/gas/all/redef3.s b/gas/testsuite/gas/all/redef3.s
new file mode 100644 (file)
index 0000000..2296d74
--- /dev/null
@@ -0,0 +1,12 @@
+ .data
+here:
+ .set sym, here
+ .long sym
+ .set sym, 0x11111111
+ .long sym
+ .set sym, xtrn
+ .long sym
+ .set sym, 0x22222222
+ .long sym
+ .comm sym, 1
+ .long sym
diff --git a/gas/testsuite/gas/all/redef4.s b/gas/testsuite/gas/all/redef4.s
new file mode 100644 (file)
index 0000000..8bd3943
--- /dev/null
@@ -0,0 +1,3 @@
+ .data
+sym:
+ .set sym, 0
diff --git a/gas/testsuite/gas/all/redef5.s b/gas/testsuite/gas/all/redef5.s
new file mode 100644 (file)
index 0000000..8a3a67a
--- /dev/null
@@ -0,0 +1,2 @@
+ .comm sym, 1
+ .set sym, 0
index d62e302d52b4a9658deafff60d1f894800022034..6e5daeabc36b60b6a28e3e944b040b6841b543ba 100644 (file)
@@ -1,6 +1,5 @@
 #objdump: -t
 #name: .equ redefinitions (ELF)
-#source: ../all/redef2.s
 
 .*: .*
 
diff --git a/gas/testsuite/gas/elf/redef.s b/gas/testsuite/gas/elf/redef.s
new file mode 100644 (file)
index 0000000..3e975e1
--- /dev/null
@@ -0,0 +1,10 @@
+ .data
+here:
+ .set sym, here
+ .long sym
+ .set sym, 0x11111111
+ .long sym
+ .set sym, xtrn
+ .long sym
+ .set sym, 0x22222222
+ .long sym