gas/
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 3 Mar 2008 15:28:58 +0000 (15:28 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 3 Mar 2008 15:28:58 +0000 (15:28 +0000)
2008-03-03  Denys Vlasenko <vda.linux@googlemail.com>
    H.J. Lu  <hongjiu.lu@intel.com>

PR gas/5543
* read.c (pseudo_set): Don't allow global register symbol.

* symbols.c (S_SET_EXTERNAL): Don't allow register symbol
global.

2008-03-03  H.J. Lu  <hongjiu.lu@intel.com>

PR gas/5543
* write.c (write_object_file): Don't allow symbols which were
equated to register.  Stop if there is an error.

gas/testsuite/

2008-03-03  H.J. Lu  <hongjiu.lu@intel.com>

PR gas/5543
* gas/i386/i386.exp: Run inval-equ-1 and inval-equ-2.

* gas/i386/inval-equ-1.l: New.
* gas/i386/inval-equ-1.s: Likewise.
* gas/i386/inval-equ-2.l: Likewise.
* gas/i386/inval-equ-2.s: Likewise.

gas/ChangeLog
gas/read.c
gas/symbols.c
gas/testsuite/ChangeLog
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/inval-equ-1.l [new file with mode: 0644]
gas/testsuite/gas/i386/inval-equ-1.s [new file with mode: 0644]
gas/testsuite/gas/i386/inval-equ-2.l [new file with mode: 0644]
gas/testsuite/gas/i386/inval-equ-2.s [new file with mode: 0644]
gas/write.c

index f577d0bfe88030deb8b5d3f14fc37707092c2ead..99c63faa68776e55ca4dc09616d5d88ca9298d2f 100644 (file)
@@ -1,3 +1,18 @@
+2008-03-03  Denys Vlasenko <vda.linux@googlemail.com>
+           H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/5543
+       * read.c (pseudo_set): Don't allow global register symbol.
+
+       * symbols.c (S_SET_EXTERNAL): Don't allow register symbol
+       global.
+
+2008-03-03  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/5543
+       * write.c (write_object_file): Don't allow symbols which were
+       equated to register.  Stop if there is an error.
+
 2008-03-01  Alan Modra  <amodra@bigpond.net.au>
 
        * config/tc-ppc.h (struct _ppc_fix_extra): New.
index ed3be3743b0381271933ffc34832d799ff967661..8163c5ababb1af2623235adae18be12fde2ec601 100644 (file)
@@ -3604,6 +3604,12 @@ pseudo_set (symbolS *symbolP)
       break;
 
     case O_register:
+      if (S_IS_EXTERNAL (symbolP))
+       {
+         as_bad ("can't equate global symbol `%s' with register name",
+                 S_GET_NAME (symbolP));
+         return;
+       }
       S_SET_SEGMENT (symbolP, reg_section);
       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
       set_zero_frag (symbolP);
index b631a1d6aa4eea8a0363209e583c51202ac397f0..252cfcef4eca8a5c39c25c9d08a763fd181090e3 100644 (file)
@@ -2184,6 +2184,12 @@ S_SET_EXTERNAL (symbolS *s)
                     _("section symbols are already global"));
       return;
     }
+  if (S_GET_SEGMENT (s) == reg_section)
+    {
+      as_bad ("can't make register symbol `%s' global",
+             S_GET_NAME (s));
+      return;
+    }
   s->bsym->flags |= BSF_GLOBAL;
   s->bsym->flags &= ~(BSF_LOCAL | BSF_WEAK);
 
index df138a3a02d29e489cfa5c4ed288c779af797baa..deef67544b163bf835251329a79691cb6bda1624 100644 (file)
@@ -1,3 +1,12 @@
+2008-03-03  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/5543
+       * gas/i386/i386.exp: Run inval-equ-1 and inval-equ-2.
+
+       * gas/i386/inval-equ-1.l: New.
+       * gas/i386/inval-equ-1.s: Likewise.
+       * gas/i386/inval-equ-2.l: Likewise.
+       * gas/i386/inval-equ-2.s: Likewise.
 
 2008-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
index 442e235bb165468aae3e35edf57c41b63687421d..30459e9b9b5242c29c241a3484178ca498ef862e 100644 (file)
@@ -148,6 +148,8 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
        run_dump_test "mixed-mode-reloc32"
        run_dump_test "att-regs"
        run_dump_test "intel-regs"
+       run_list_test "inval-equ-1" "-al"
+       run_list_test "inval-equ-2" "-al"
     }
 
     # This is a PE specific test.
diff --git a/gas/testsuite/gas/i386/inval-equ-1.l b/gas/testsuite/gas/i386/inval-equ-1.l
new file mode 100644 (file)
index 0000000..decda65
--- /dev/null
@@ -0,0 +1,14 @@
+.*: Assembler messages:
+.*:3: Error: .*
+.*:5: Error: .*
+GAS LISTING .*
+
+
+[      ]*1[    ]+\.text
+[      ]*2[    ]+\.globl  bar1
+[      ]*3[    ]+\.equ    bar1,%eax
+[      ]*4[    ]+\.equ    bar2,%eax
+[      ]*5[    ]+\.globl  bar2
+[      ]*6[    ]+\?\?\?\? A1000000             mov bar1,%eax
+[      ]*6[    ]+00
+[      ]*7[    ]+\?\?\?\? 89C0                 mov bar2,%eax
diff --git a/gas/testsuite/gas/i386/inval-equ-1.s b/gas/testsuite/gas/i386/inval-equ-1.s
new file mode 100644 (file)
index 0000000..fd5ed48
--- /dev/null
@@ -0,0 +1,7 @@
+       .text
+       .globl  bar1
+       .equ    bar1,%eax
+       .equ    bar2,%eax
+       .globl  bar2
+       mov bar1,%eax
+       mov bar2,%eax
diff --git a/gas/testsuite/gas/i386/inval-equ-2.l b/gas/testsuite/gas/i386/inval-equ-2.l
new file mode 100644 (file)
index 0000000..d598d0b
--- /dev/null
@@ -0,0 +1,19 @@
+.*: Assembler messages:
+.*:8: Error: .*
+.*:8: Error: .*
+.*:8: Error: .*
+GAS LISTING .*
+
+
+[      ]*1[    ]+\.globl  bar1
+[      ]*2[    ]+\.set    bar1,\(%eax\+1\)
+[      ]*3[    ]+\?\?\?\? A12A0000             mov bar1,%eax
+[      ]*3[    ]+00
+[      ]*4[    ]+\.set    bar2,\(%eax\+1\)
+[      ]*5[    ]+\?\?\?\? A12A0000             mov bar2,%eax
+[      ]*5[    ]+00
+[      ]*6[    ]+\.globl  bar2
+[      ]*7[    ]+\.set    bar3,\(%eax\+1\)
+[      ]*8[    ]+\?\?\?\? A12A0000             mov bar3,%eax
+\*\*\*\*  Error:can't make global register symbol `bar3'
+[      ]*8[    ]+00
diff --git a/gas/testsuite/gas/i386/inval-equ-2.s b/gas/testsuite/gas/i386/inval-equ-2.s
new file mode 100644 (file)
index 0000000..90caa25
--- /dev/null
@@ -0,0 +1,8 @@
+       .globl  bar1
+       .set    bar1,(%eax+1)
+       mov bar1,%eax
+       .set    bar2,(%eax+1)
+       mov bar2,%eax
+       .globl  bar2
+       .set    bar3,(%eax+1)
+       mov bar3,%eax
index 03641dfa4b320618b2a37911b32eeb9572347ba4..9875f7f68728b3b2a42cc73152cb2c59861abf85 100644 (file)
@@ -1763,6 +1763,13 @@ write_object_file (void)
                  as_bad (_("Local symbol `%s' can't be equated to common symbol `%s'"),
                          name, S_GET_NAME (e->X_add_symbol));
                }
+             if (S_GET_SEGMENT (symp) == reg_section)
+               {
+                 /* Report error only if we know the symbol name.  */
+                 if (S_GET_NAME (symp) != reg_section->name)
+                   as_bad (_("can't make global register symbol `%s'"),
+                           name);
+               }
              symbol_remove (symp, &symbol_rootP, &symbol_lastP);
              continue;
            }
@@ -1830,6 +1837,10 @@ write_object_file (void)
   obj_adjust_symtab ();
 #endif
 
+  /* Stop if there is an error.  */
+  if (had_errors ())
+    return;
+
   /* Now that all the sizes are known, and contents correct, we can
      start writing to the file.  */
   set_symtab ();