PATCH: Add -munwind-check=[none|warning|error]

H. J. Lu hjl@lucon.org
Sat Feb 12 06:28:00 GMT 2005


On Fri, Feb 11, 2005 at 10:45:11AM -0800, H. J. Lu wrote:
> On Thu, Feb 10, 2005 at 06:30:17PM -0800, James E Wilson wrote:
> > On Thu, 2005-02-10 at 09:29, H. J. Lu wrote:
> > > Here is the updated patch to add -munwind-check=[none|warning|error].
> > > I documented this new option.
> > 
> > My feeling on this issue in general that we should be emitting a
> > diagnostic here always.  This new code is finding latent bugs in the
> > unwind info.  This is a correctness issue.  If we let the latent bugs
> > through, then they will only be found if an exception is generated and
> > the stack unwound, at which point it is far too late to recover from the
> > mistake.  This makes it very important for the assembler to give a
> > diagnostic when we find a problem.  I can live with this being a warning
> > for now, to avoid compatibility problems, but it really is important
> > that people fix their code if they want it to work correctly.
> > 
> 
> Here is the new patch. I removed the -munwind-check=none option. I also
> included the patch for the .endp check. IAS does ignore the name
> after .endp. But checking it is a good idea. People will get a
> warning unless they fix the code.
> 
> 

It turned out that I need to return non-0 for warnings to work. Also
I need to return -1 to indicate that a warning has been issued so
that a second one isn't needed.


H.J.
------
2005-02-11  H.J. Lu  <hongjiu.lu@intel.com>

	* config/tc-ia64.c (unwind_diagnostic): Return -1 for warning
	and 0 for error.
	(in_procedure): Return -1 for warning.
	(in_prologue): Likewise.
	(in_body): Likewise.

--- gas/config/tc-ia64.c.warn	2005-02-11 13:21:20.056751130 -0800
+++ gas/config/tc-ia64.c	2005-02-11 15:08:03.424884229 -0800
@@ -3063,50 +3063,80 @@ dot_special_section (which)
   set_section ((char *) special_section_name[which]);
 }
 
-static void
+/* Return -1 for warning and 0 for error.  */
+
+static int
 unwind_diagnostic (const char * region, const char *directive)
 {
   if (md.unwind_check == unwind_check_warning)
-    as_warn (".%s outside of %s", directive, region);
+    {
+      as_warn (".%s outside of %s", directive, region);
+      return -1;
+    }
   else
     {
       as_bad (".%s outside of %s", directive, region);
       ignore_rest_of_line ();
+      return 0;
     }
 }
 
+/* Return 1 if a directive is in a procedure, -1 if a diretive isn't in
+   a procedure but the unwind diretive check is set to warning, 0 if
+   a diretive isn't in a procedure and the unwind diretive check is set
+   to error.  */
+
 static int
 in_procedure (const char *directive)
 {
   if (unwind.proc_start
       && (!unwind.saved_text_seg || strcmp (directive, "endp") == 0))
     return 1;
-  unwind_diagnostic ("procedure", directive);
-  return 0;
+  return unwind_diagnostic ("procedure", directive);
 }
 
+/* Return 1 if a directive is in a prologue, -1 if a diretive isn't in
+   a prologue but the unwind diretive check is set to warning, 0 if
+   a diretive isn't in a prologue and the unwind diretive check is set
+   to error.  */
+
 static int
 in_prologue (const char *directive)
 {
-  if (in_procedure (directive))
+  int in = in_procedure (directive);
+  if (in)
     {
       /* We are in a procedure. Check if we are in a prologue.  */
       if (unwind.prologue)
 	return 1;
-      unwind_diagnostic ("prologue", directive);
+      /* We only want to issue one message.  */
+      if (in == 1)
+	return unwind_diagnostic ("prologue", directive);
+      else
+	return -1;
     }
   return 0;
 }
 
+/* Return 1 if a directive is in a body, -1 if a diretive isn't in
+   a body but the unwind diretive check is set to warning, 0 if
+   a diretive isn't in a body and the unwind diretive check is set
+   to error.  */
+
 static int
 in_body (const char *directive)
 {
-  if (in_procedure (directive))
+  int in = in_procedure (directive);
+  if (in)
     {
       /* We are in a procedure. Check if we are in a body.  */
       if (unwind.body)
 	return 1;
-      unwind_diagnostic ("body region", directive);
+      /* We only want to issue one message.  */
+      if (in == 1)
+	return unwind_diagnostic ("body region", directive);
+      else
+	return -1;
     }
   return 0;
 }



More information about the Binutils mailing list