]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/read.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gas / read.c
index 2484ae080ea73a7e6f783073a14b13c5f2a857fa..fd2aa66f7b66f94075bf563cca5224ab87312492 100644 (file)
@@ -296,6 +296,7 @@ static const pseudo_typeS potable[] =
   {"elsec", s_else, 0},
   {"end", s_end, 0},
   {"endc", s_endif, 0},
+  {"endfunc", s_func, 1},
   {"endif", s_endif, 0},
 /* endef */
   {"equ", s_set, 0},
@@ -311,6 +312,7 @@ static const pseudo_typeS potable[] =
   {"fill", s_fill, 0},
   {"float", float_cons, 'f'},
   {"format", s_ignore, 0},
+  {"func", s_func, 0},
   {"global", s_globl, 0},
   {"globl", s_globl, 0},
   {"hword", cons, 2},
@@ -1295,10 +1297,10 @@ s_align (arg, bytes_p)
        }
     }
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 /* Handle the .align pseudo-op on machines where ".align 4" means
@@ -1345,18 +1347,18 @@ s_comm (ignore)
   if (*input_line_pointer != ',')
     {
       as_bad (_("Expected comma after symbol-name: rest of line ignored."));
+      ignore_rest_of_line ();
       if (flag_mri)
        mri_comment_end (stop, stopc);
-      ignore_rest_of_line ();
       return;
     }
   input_line_pointer++;                /* skip ',' */
   if ((temp = get_absolute_expression ()) < 0)
     {
       as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp);
+      ignore_rest_of_line ();
       if (flag_mri)
        mri_comment_end (stop, stopc);
-      ignore_rest_of_line ();
       return;
     }
   *p = 0;
@@ -1366,9 +1368,9 @@ s_comm (ignore)
     {
       as_bad (_("Ignoring attempt to re-define symbol `%s'."),
              S_GET_NAME (symbolP));
+      ignore_rest_of_line ();
       if (flag_mri)
        mri_comment_end (stop, stopc);
-      ignore_rest_of_line ();
       return;
     }
   if (S_GET_VALUE (symbolP))
@@ -1393,10 +1395,10 @@ s_comm (ignore)
 #endif /* not OBJ_VMS */
   know (symbolP->sy_frag == &zero_address_frag);
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }                              /* s_comm() */
 
 /* The MRI COMMON pseudo-op.  We handle this by creating a common
@@ -1464,8 +1466,8 @@ s_mri_common (small)
   if (S_IS_DEFINED (sym) && ! S_IS_COMMON (sym))
     {
       as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym));
-      mri_comment_end (stop, stopc);
       ignore_rest_of_line ();
+      mri_comment_end (stop, stopc);
       return;
     }
 
@@ -1495,9 +1497,9 @@ s_mri_common (small)
   if (*input_line_pointer == ',')
     input_line_pointer += 2;
 
-  mri_comment_end (stop, stopc);
-
   demand_empty_rest_of_line ();
+
+  mri_comment_end (stop, stopc);
 }
 
 void
@@ -1645,10 +1647,10 @@ s_fail (ignore)
   else
     as_bad (_(".fail %ld encountered"), (long) temp);
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 void 
@@ -1779,10 +1781,10 @@ s_globl (ignore)
     }
   while (c == ',');
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 /* Handle the MRI IRP and IRPC pseudo-ops.  */
@@ -2297,13 +2299,19 @@ s_mri (ignore)
 #ifdef TC_M68K
       flag_m68k_mri = 1;
 #endif
+      macro_mri_mode (1);
     }
   else
     {
       flag_mri = 0;
       flag_m68k_mri = 0;
+      macro_mri_mode (0);
     }
 
+  /* Operator precedence changes in m68k MRI mode, so we need to
+     update the operator rankings.  */
+  expr_set_precedence ();
+
 #ifdef MRI_MODE_CHANGE
   if (on != old_flag)
     MRI_MODE_CHANGE (on);
@@ -2887,10 +2895,10 @@ s_space (mult)
   if (flag_mri && (bytes & 1) != 0)
     mri_pending_align = 1;
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 /* This is like s_space, but the value is a floating point number with
@@ -2916,9 +2924,9 @@ s_float_space (float_type)
   if (*input_line_pointer != ',')
     {
       as_bad (_("missing value"));
+      ignore_rest_of_line ();
       if (flag_mri)
        mri_comment_end (stop, stopc);
-      ignore_rest_of_line ();
       return;
     }
 
@@ -2939,9 +2947,9 @@ s_float_space (float_type)
       flen = hex_float (float_type, temp);
       if (flen < 0)
        {
+         ignore_rest_of_line ();
          if (flag_mri)
            mri_comment_end (stop, stopc);
-         ignore_rest_of_line ();
          return;
        }
     }
@@ -2955,9 +2963,9 @@ s_float_space (float_type)
       if (err)
        {
          as_bad (_("Bad floating literal: %s"), err);
+         ignore_rest_of_line ();
          if (flag_mri)
            mri_comment_end (stop, stopc);
-         ignore_rest_of_line ();
          return;
        }
     }
@@ -2970,10 +2978,10 @@ s_float_space (float_type)
       memcpy (p, temp, (unsigned int) flen);
     }
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 /* Handle the .struct pseudo-op, as found in MIPS assemblers.  */
@@ -2989,9 +2997,9 @@ s_struct (ignore)
     stop = mri_comment_field (&stopc);
   abs_section_offset = get_absolute_expression ();
   subseg_set (absolute_section, 0);
+  demand_empty_rest_of_line ();
   if (flag_mri)
     mri_comment_end (stop, stopc);
-  demand_empty_rest_of_line ();
 }
 
 void
@@ -3217,9 +3225,9 @@ cons_worker (nbytes, rva)
 
   if (is_it_end_of_statement ())
     {
+      demand_empty_rest_of_line ();
       if (flag_mri)
        mri_comment_end (stop, stopc);
-      demand_empty_rest_of_line ();
       return;
     }
 
@@ -3255,10 +3263,10 @@ cons_worker (nbytes, rva)
 
   input_line_pointer--;                /* Put terminator back into stream. */
 
+  demand_empty_rest_of_line ();
+
   if (flag_mri)
     mri_comment_end (stop, stopc);
-
-  demand_empty_rest_of_line ();
 }
 
 
@@ -3431,8 +3439,8 @@ emit_expr (exp, nbytes)
       x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
       x->next_broken_word = broken_words;
       broken_words = x;
-      x->seg = seg_now;
-      x->subseg = subseg_now;
+      x->seg = now_seg;
+      x->subseg = now_subseg;
       x->frag = frag_now;
       x->word_goes_here = p;
       x->dispfrag = 0;
@@ -4388,7 +4396,7 @@ stringer (append_zero)            /* Worker to do .ascii etc statements. */
 
   /*
    * The following awkward logic is to parse ZERO or more strings,
-   * comma seperated. Recall a string expression includes spaces
+   * comma separated. Recall a string expression includes spaces
    * before the opening '\"' and spaces after the closing '\"'.
    * We fake a leading ',' if there is (supposed to be)
    * a 1st, expression. We keep demanding expressions for each
@@ -4781,7 +4789,10 @@ equals (sym_name, reassign)
     }
 
   if (flag_mri)
-    mri_comment_end (stop, stopc);
+     {
+       ignore_rest_of_line (); /* check garbage after the expression */
+       mri_comment_end (stop, stopc);
+     }
 }                              /* equals() */
 
 /* .include -- include a file at this point. */
@@ -4871,7 +4882,7 @@ add_include_dir (path)
   if (i > include_dir_maxlen)
     include_dir_maxlen = i;
 }                              /* add_include_dir() */
-
+\f
 /* Output debugging information to denote the source file.  */
 
 static void
@@ -4886,32 +4897,125 @@ generate_file_debug ()
 static void
 generate_lineno_debug ()
 {
-  if (debug_type == DEBUG_STABS)
-    stabs_generate_asm_lineno ();
-
-#ifdef OBJ_GENERATE_ASM_LINENO
 #ifdef ECOFF_DEBUGGING
-  /* ECOFF assemblers automatically generate
-     debugging information.  FIXME: This should
-     probably be handled elsewhere.  */
-  if (debug_type == DEBUG_NONE)
+  /* ECOFF assemblers automatically generate debugging information. 
+     FIXME: This should probably be handled elsewhere.  */
+  if (debug_type == DEBUG_UNSPECIFIED)
     {
-      if (ecoff_no_current_file ())
-       debug_type = DEBUG_ECOFF;
+      if (ECOFF_DEBUGGING && ecoff_no_current_file ())
+        debug_type = DEBUG_ECOFF;
+      else
+       debug_type = DEBUG_NONE;
     }
+#endif
 
-  if (debug_type == DEBUG_ECOFF)
+  switch (debug_type)
     {
-      unsigned int lineno;
-      char *s;
+      case DEBUG_UNSPECIFIED:
+      case DEBUG_NONE:
+       break;
+      case DEBUG_STABS:
+       stabs_generate_asm_lineno ();
+       break;
+      case DEBUG_ECOFF:
+       ecoff_generate_asm_lineno ();
+       break;
+    }
+}
+
+/* Output debugging information to mark a function entry point or end point.
+   END_P is zero for .func, and non-zero for .endfunc.  */
+
+void
+s_func (end_p)
+     int end_p;
+{
+  do_s_func (end_p, NULL);
+}
+
+/* Subroutine of s_func so targets can choose a different default prefix.
+   If DEFAULT_PREFIX is NULL, use the target's "leading char".  */
+
+void
+do_s_func (end_p, default_prefix)
+     int end_p;
+     const char *default_prefix;
+{
+  /* Record the current function so that we can issue an error message for
+     misplaced .func,.endfunc, and also so that .endfunc needs no
+     arguments.  */
+  static char *current_name;
+  static char *current_label;
+
+  if (end_p)
+    {
+      if (current_name == NULL)
+       {
+         as_bad (_("missing .func"));
+         ignore_rest_of_line ();
+         return;
+       }
 
-      as_where (&s, &lineno);
-      OBJ_GENERATE_ASM_LINENO (s, lineno);
+      if (debug_type == DEBUG_STABS)
+       stabs_generate_asm_endfunc (current_name, current_label);
+
+      current_name = current_label = NULL;
     }
+  else /* ! end_p */
+    {
+      char *name,*label;
+      char delim1,delim2;
+
+      if (current_name != NULL)
+       {
+         as_bad (_(".endfunc missing for previous .func"));
+         ignore_rest_of_line ();
+         return;
+       }
+
+      name = input_line_pointer;
+      delim1 = get_symbol_end ();
+      name = xstrdup (name);
+      *input_line_pointer = delim1;
+      SKIP_WHITESPACE ();
+      if (*input_line_pointer != ',')
+       {
+         if (default_prefix)
+           asprintf (&label, "%s%s", default_prefix, name);
+         else
+           {
+             char leading_char = 0;
+#ifdef BFD_ASSEMBLER
+             leading_char = bfd_get_symbol_leading_char (stdoutput);
 #endif
-#endif
-}
+             /* Missing entry point, use function's name with the leading
+                char prepended.  */
+             if (leading_char)
+               asprintf (&label, "%c%s", leading_char, name);
+             else
+               label = name;
+           }
+       }
+      else
+       {
+         ++input_line_pointer;
+         SKIP_WHITESPACE ();
+         label = input_line_pointer;
+         delim2 = get_symbol_end ();
+         label = xstrdup (label);
+         *input_line_pointer = delim2;
+       }
+
+      if (debug_type == DEBUG_STABS)
+       stabs_generate_asm_func (name, label);
+
+      current_name = name;
+      current_label = label;
+    }
 
+  demand_empty_rest_of_line ();
+}
+\f
 void 
 s_ignore (arg)
      int arg;