* config/obj-elf.c (get_sym_from_input_line_and_check): New
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 15 Jul 2010 14:34:42 +0000 (14:34 +0000)
committerNathan Sidwell <nathan@codesourcery.com>
Thu, 15 Jul 2010 14:34:42 +0000 (14:34 +0000)
function to catch missing pseudo-op arguments.
(obj_elf_local): Call new function.
(obj_elf_weak): Likewise.
(obj_elf_visibility): Likewise.
(obj_elf_vtable_entry): Likewise.
(obj_elf_type): Likewise.

testsuite/
* gas/elf/pseudo.s: New.
* gas/elf/pseudo.l: New.
* gas/elf/pseudo.d: New.
* gas/elf/elf.exp: Run the new test.

gas/ChangeLog
gas/config/obj-elf.c
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/pseudo.d [new file with mode: 0644]
gas/testsuite/gas/elf/pseudo.l [new file with mode: 0644]
gas/testsuite/gas/elf/pseudo.s [new file with mode: 0644]

index 7f541c58f3354cdc45edbfdb004f279c0d08bfb5..2a0f2911b17bad23921b72ab04804569334fd69b 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-15  Rhonda Wittels  <rhonda@codesourcery.com>
+
+       * config/obj-elf.c (get_sym_from_input_line_and_check): New
+       function to catch missing pseudo-op arguments.
+       (obj_elf_local): Call new function.
+       (obj_elf_weak): Likewise.
+       (obj_elf_visibility): Likewise.
+       (obj_elf_vtable_entry): Likewise.
+       (obj_elf_type): Likewise.
+
 2010-07-15  Kai Tietz  <kai.tietz@onevision.com>
 
        * config/obj-coff-seh.c
index 3ffe6e9dd16dfa0b7c3f9a37c302d391c6343191..b123b6b1b8e1dff5f3345376f8401adc97c95eac 100644 (file)
@@ -393,20 +393,35 @@ obj_elf_lcomm (int ignore ATTRIBUTE_UNUSED)
     symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
 }
 
+static symbolS *
+get_sym_from_input_line_and_check (void)
+{
+  char *name;
+  char c;
+  symbolS *sym;
+
+  name = input_line_pointer;
+  c = get_symbol_end ();
+  sym = symbol_find_or_make (name);
+  *input_line_pointer = c;
+  SKIP_WHITESPACE ();
+
+  /* There is no symbol name if input_line_pointer has not moved.  */
+  if (name == input_line_pointer)
+    as_bad (_("Missing symbol name in directive"));
+  return sym;
+}
+
 static void
 obj_elf_local (int ignore ATTRIBUTE_UNUSED)
 {
-  char *name;
   int c;
   symbolS *symbolP;
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
-      symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
-      SKIP_WHITESPACE ();
+      symbolP = get_sym_from_input_line_and_check (); 
+      c = *input_line_pointer;
       S_CLEAR_EXTERNAL (symbolP);
       symbol_get_obj (symbolP)->local = 1;
       if (c == ',')
@@ -424,17 +439,13 @@ obj_elf_local (int ignore ATTRIBUTE_UNUSED)
 static void
 obj_elf_weak (int ignore ATTRIBUTE_UNUSED)
 {
-  char *name;
   int c;
   symbolS *symbolP;
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
-      symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
-      SKIP_WHITESPACE ();
+      symbolP = get_sym_from_input_line_and_check (); 
+      c = *input_line_pointer;
       S_SET_WEAK (symbolP);
       symbol_get_obj (symbolP)->local = 1;
       if (c == ',')
@@ -452,7 +463,6 @@ obj_elf_weak (int ignore ATTRIBUTE_UNUSED)
 static void
 obj_elf_visibility (int visibility)
 {
-  char *name;
   int c;
   symbolS *symbolP;
   asymbol *bfdsym;
@@ -460,12 +470,7 @@ obj_elf_visibility (int visibility)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
-      symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
-
-      SKIP_WHITESPACE ();
+      symbolP = get_sym_from_input_line_and_check ();
 
       bfdsym = symbol_get_bfdsym (symbolP);
       elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym);
@@ -475,6 +480,7 @@ obj_elf_visibility (int visibility)
       elfsym->internal_elf_sym.st_other &= ~3;
       elfsym->internal_elf_sym.st_other |= visibility;
 
+      c = *input_line_pointer;
       if (c == ',')
        {
          input_line_pointer ++;
@@ -1242,14 +1248,8 @@ obj_elf_symver (int ignore ATTRIBUTE_UNUSED)
   char old_lexat;
   symbolS *sym;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
+  sym = get_sym_from_input_line_and_check ();
 
-  sym = symbol_find_or_make (name);
-
-  *input_line_pointer = c;
-
-  SKIP_WHITESPACE ();
   if (*input_line_pointer != ',')
     {
       as_bad (_("expected comma after name in .symver"));
@@ -1378,20 +1378,13 @@ obj_elf_vtable_inherit (int ignore ATTRIBUTE_UNUSED)
 struct fix *
 obj_elf_vtable_entry (int ignore ATTRIBUTE_UNUSED)
 {
-  char *name;
   symbolS *sym;
   offsetT offset;
-  char c;
 
   if (*input_line_pointer == '#')
     ++input_line_pointer;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
-  sym = symbol_find_or_make (name);
-  *input_line_pointer = c;
-
-  SKIP_WHITESPACE ();
+  sym = get_sym_from_input_line_and_check ();
   if (*input_line_pointer != ',')
     {
       as_bad (_("expected comma after name in .vtable_entry"));
@@ -1613,20 +1606,16 @@ obj_elf_type_name (char *cp)
 static void
 obj_elf_type (int ignore ATTRIBUTE_UNUSED)
 {
-  char *name;
   char c;
   int type;
   const char *type_name;
   symbolS *sym;
   elf_symbol_type *elfsym;
 
-  name = input_line_pointer;
-  c = get_symbol_end ();
-  sym = symbol_find_or_make (name);
+  sym = get_sym_from_input_line_and_check ();
+  c = *input_line_pointer;
   elfsym = (elf_symbol_type *) symbol_get_bfdsym (sym);
-  *input_line_pointer = c;
 
-  SKIP_WHITESPACE ();
   if (*input_line_pointer == ',')
     ++input_line_pointer;
 
index f0ca9e07ff6970bc762e27823d1625af5a1e18ef..aca2626d1c737112e22d7010b1270773f81d441f 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-14  Rhonda Wittels  <rhonda@codesourcery.com>
+
+       * gas/elf/pseudo.s: New.
+       * gas/elf/pseudo.l: New.
+       * gas/elf/pseudo.d: New.
+       * gas/elf/elf.exp: Run the new test.
+
 2010-07-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/default.exp (ADDR2LINE): New.
index b2a29aace4062cdb6c196e20dc46b962b9cb6f93..55a08b1da036dcb5799f7dc29c4ec9e05bbd142c 100644 (file)
@@ -127,6 +127,7 @@ if { ([istarget "*-*-*elf*"]
            run_dump_test equ-reloc
        }
     }
+    run_dump_test "pseudo"
     run_dump_test "section0" 
     run_dump_test "section1" 
     if {! [istarget "h8300-*-*"]} then {
diff --git a/gas/testsuite/gas/elf/pseudo.d b/gas/testsuite/gas/elf/pseudo.d
new file mode 100644 (file)
index 0000000..59d4801
--- /dev/null
@@ -0,0 +1,2 @@
+#name: Ill-formed directives
+#error-output: pseudo.l
diff --git a/gas/testsuite/gas/elf/pseudo.l b/gas/testsuite/gas/elf/pseudo.l
new file mode 100644 (file)
index 0000000..605f5b8
--- /dev/null
@@ -0,0 +1,12 @@
+[^:]*: Assembler messages:
+[^:]*:2: Error: Missing symbol name in directive
+[^:]*:4: Error: Missing symbol name in directive
+[^:]*:6: Error: Missing symbol name in directive
+[^:]*:8: Error: Missing symbol name in directive
+[^:]*:10: Error: Missing symbol name in directive
+[^:]*:12: Error: Missing symbol name in directive
+[^:]*:14: Error: Missing symbol name in directive
+[^:]*:14: Error: expected comma after name in .symver
+[^:]*:16: Error: Missing symbol name in directive
+[^:]*:18: Error: Missing symbol name in directive
+[^:]*:18: Error: unrecognized symbol type ""
diff --git a/gas/testsuite/gas/elf/pseudo.s b/gas/testsuite/gas/elf/pseudo.s
new file mode 100644 (file)
index 0000000..971f8fb
--- /dev/null
@@ -0,0 +1,18 @@
+       .hidden h1n1
+       .hidden
+       # next line has spaces
+       .hidden                
+       # next line has tabs
+       .hidden                 
+       .internal i2
+       .internal
+       .protected porpoise
+       .protected 
+       .local foo
+       .local
+       .symver foo, foo@version1
+       .symver
+       .weak wimp
+       .weak
+       .type foo1,object
+       .type