This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Add --size-check=[error|warning]
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