public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, binutils@sourceware.org
Subject: Re: PATCH: Add --size-check=[error|warning]
Date: Fri, 18 Mar 2011 11:59:00 -0000	[thread overview]
Message-ID: <20110318115912.GD13754@bubble.grove.modra.org> (raw)
In-Reply-To: <20110318112002.GC13754@bubble.grove.modra.org>

And for 2.21.

	* config/obj-elf.c (elf_frob_symbol): Report S_SET_SIZE symbol
	on .size expression errors rather than symbols in the size expression.

	Backport 2011-03-16  H.J. Lu  <hongjiu.lu@intel.com>
	* as.c (show_usage): Add --size-check=.
	(parse_args): Add and handle OPTION_SIZE_CHECK.
	* as.h (flag_size_check): New.
	* config/obj-elf.c (elf_frob_symbol): Use as_bad to report
	bad .size directive only for --size-check=error.
	* doc/as.texinfo: Document --size-check=.

Index: gas/as.c
===================================================================
RCS file: /cvs/src/src/gas/as.c,v
retrieving revision 1.92.2.1
diff -u -p -r1.92.2.1 as.c
--- gas/as.c	1 Feb 2011 12:25:40 -0000	1.92.2.1
+++ gas/as.c	18 Mar 2011 11:49:05 -0000
@@ -1,6 +1,7 @@
 /* as.c - GAS main program.
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+   2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -283,6 +284,9 @@ Options:\n\
   --execstack             require executable stack for this object\n"));
   fprintf (stream, _("\
   --noexecstack           don't require executable stack for this object\n"));
+  fprintf (stream, _("\
+  --size-check=[error|warning]\n\
+			  ELF .size directive check (default --size-check=error)\n"));
 #endif
   fprintf (stream, _("\
   -f                      skip whitespace and comment preprocessing\n"));
@@ -442,6 +446,7 @@ parse_args (int * pargc, char *** pargv)
       OPTION_TARGET_HELP,
       OPTION_EXECSTACK,
       OPTION_NOEXECSTACK,
+      OPTION_SIZE_CHECK,
       OPTION_ALTERNATE,
       OPTION_AL,
       OPTION_HASH_TABLE_SIZE,
@@ -475,6 +480,7 @@ parse_args (int * pargc, char *** pargv)
 #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
     ,{"execstack", no_argument, NULL, OPTION_EXECSTACK}
     ,{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK}
+    ,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
 #endif
     ,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
     ,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
@@ -812,6 +818,15 @@ This program has absolutely no warranty.
 	  flag_noexecstack = 1;
 	  flag_execstack = 0;
 	  break;
+
+	case OPTION_SIZE_CHECK:
+	  if (strcasecmp (optarg, "error") == 0)
+	    flag_size_check = size_check_error;
+	  else if (strcasecmp (optarg, "warning") == 0)
+	    flag_size_check = size_check_warning;
+	  else
+	    as_fatal (_("Invalid --size-check= option: `%s'"), optarg);
+	  break;
 #endif
 	case 'Z':
 	  flag_always_generate_output = 1;
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.68
diff -u -p -r1.68 as.h
--- gas/as.h	3 Jul 2010 20:52:24 -0000	1.68
+++ gas/as.h	18 Mar 2011 11:49:06 -0000
@@ -1,7 +1,7 @@
 /* as.h - global header file
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2011 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -575,6 +575,16 @@ COMMON unsigned int  found_comment;
 COMMON char *        found_comment_file;
 #endif
 
+#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
+/* If .size directive failure should be error or warning.  */
+COMMON enum
+  {
+    size_check_error = 0,
+    size_check_warning
+  }
+flag_size_check;
+#endif
+
 #ifndef DOLLAR_AMBIGU
 #define DOLLAR_AMBIGU 0
 #endif
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.133.2.4
diff -u -p -r1.133.2.4 obj-elf.c
--- gas/config/obj-elf.c	25 Feb 2011 13:46:36 -0000	1.133.2.4
+++ gas/config/obj-elf.c	18 Mar 2011 11:49:08 -0000
@@ -1893,7 +1893,14 @@ elf_frob_symbol (symbolS *symp, int *pun
 	  && sy_obj->size->X_op == O_constant)
 	S_SET_SIZE (symp, sy_obj->size->X_add_number);
       else
-	as_bad (_(".size expression does not evaluate to a constant"));
+	{
+	  if (flag_size_check == size_check_error)
+	    as_bad (_(".size expression for %s "
+		      "does not evaluate to a constant"), S_GET_NAME (symp));
+	  else
+	    as_warn (_(".size expression for %s "
+		       "does not evaluate to a constant"), S_GET_NAME (symp));
+	}
       free (sy_obj->size);
       sy_obj->size = NULL;
     }
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.225
diff -u -p -r1.225 as.texinfo
--- gas/doc/as.texinfo	2 Nov 2010 14:36:36 -0000	1.225
+++ gas/doc/as.texinfo	18 Mar 2011 11:49:13 -0000
@@ -1,6 +1,6 @@
 \input texinfo @c                               -*-Texinfo-*-
 @c  Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-@c  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+@c  2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 @c  Free Software Foundation, Inc.
 @c UPDATE!!  On future updates--
 @c   (1)   check for new machine-dep cmdline options in
@@ -103,7 +103,8 @@ This file documents the GNU Assembler "@
 
 @c man begin COPYRIGHT
 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3
@@ -153,7 +154,8 @@ done.
 
 @vskip 0pt plus 1filll
 Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+Inc.
 
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
@@ -241,6 +243,7 @@ gcc(1), ld(1), and the Info entries for 
  @var{objfile}] [@b{-R}] [@b{--reduce-memory-overheads}] [@b{--statistics}]
  [@b{-v}] [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}]
  [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] [@b{-Z}] [@b{@@@var{FILE}}]
+ [@b{--size-check=[error|warning]}]
  [@b{--target-help}] [@var{target-options}]
  [@b{--}|@var{files} @dots{}]
 @c
@@ -602,6 +610,10 @@ Generate DWARF2 debugging information fo
 may help debugging assembler code, if the debugger can handle it.  Note---this
 option is only supported by some targets, not all of them.
 
+@item --size-check=error
+@itemx --size-check=warning
+Issue an error or warning for invalid ELF .size directive.
+
 @item --help
 Print a summary of the command line options and exit.
 

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2011-03-18 11:59 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 16:58 H.J. Lu
2011-03-11 17:04 ` Jan Beulich
2011-03-11 17:20   ` H.J. Lu
2011-03-14  8:44     ` Jan Beulich
2011-03-14  9:55       ` Ingo Molnar
2011-03-14 10:41         ` Alan Modra
2011-03-14 10:50           ` Pekka Enberg
2011-03-14 18:04             ` Alan Cox
2011-03-14 10:52           ` Jan Beulich
     [not found]           ` <AANLkTi=3AiLaw5Gnis8Ha4eRXirk0s-Cnk2zzN12YDpH__45869.1711457961$1300099861$gmane$org@mail.gmail.com>
2011-03-14 11:03             ` Andreas Schwab
2011-03-14 11:12               ` Pekka Enberg
2011-03-14 12:02                 ` Andreas Schwab
2011-03-14 12:13                   ` Ingo Molnar
2011-03-14 12:55                     ` Andreas Schwab
2011-03-14 13:17                       ` Ingo Molnar
2011-03-14 14:11                         ` Andreas Schwab
2011-03-14 12:11                 ` Ingo Molnar
2011-03-14 12:23           ` Ingo Molnar
2011-03-14 12:26             ` Ingo Molnar
2011-03-14 13:16             ` git bisect plus fixes (was: PATCH: Add --size-check=[error|warning]) Ralf Wildenhues
2011-03-14 13:55       ` PATCH: Add --size-check=[error|warning] H.J. Lu
2011-03-16 23:56 ` Alan Modra
2011-03-18 11:20   ` Alan Modra
2011-03-18 11:59     ` Alan Modra [this message]
2011-03-14 11:02 Sedat Dilek
2011-03-14 11:25 ` Jan Beulich
2011-03-14 11:35   ` Ingo Molnar
2011-03-14 11:39   ` Sedat Dilek
2011-03-14 11:53     ` Sedat Dilek
2011-03-14 12:22       ` Jan Beulich
2011-03-14 12:38         ` Sedat Dilek
2011-03-14 15:56         ` Ian Lance Taylor
2011-03-14 18:02           ` H. Peter Anvin
2011-03-14 16:33   ` H. Peter Anvin
2011-03-14 19:24     ` Steven Rostedt
2011-03-14 20:06       ` Linus Torvalds
2011-03-14 12:57 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110318115912.GD13754@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).