]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* config/obj-elf.c (elf_frob_symbol): Report S_SET_SIZE symbol
authorAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2011 12:01:50 +0000 (12:01 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2011 12:01:50 +0000 (12:01 +0000)
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=.

gas/ChangeLog
gas/as.c
gas/as.h
gas/config/obj-elf.c
gas/doc/as.texinfo

index 2c2ebf7fed55a88b056d11990559477f50056a0a..ad3b55a4f97dd93f375fda648914f589e137887e 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-18  Alan Modra  <amodra@gmail.com>
+
+       * 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=.
+
 2011-03-17  Alan Modra  <amodra@gmail.com>
 
        PR 12569
index 8fe13e9714992c95012a7ec1dfc9a179d0b0dfea..380259c0284d8b1bbb2639a6160a0ff8c3095d5c 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -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.\n"));
          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 7c163826d90706972f432c590c91f4434a8c3af7..d993c74fe89aacae7cab7effe854836659f0556a 100644 (file)
--- a/gas/as.h
+++ b/gas/as.h
@@ -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 969a5091e8e8f70f1e17214d98a68bd65aef9d80..54021fc1be878f330556180de055a44a898d3f9f 100644 (file)
@@ -1893,7 +1893,14 @@ elf_frob_symbol (symbolS *symp, int *puntp)
          && 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 6a3fc8130414662508cf7d23d14a70c326af76ba..c775e142f3cdc635b79bc26fc6ab8e982f92e1e4 100644 (file)
@@ -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 "@value{AS}".
 
 @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 @file{binutils} and @file{ld}.
  @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 +605,10 @@ Generate DWARF2 debugging information for each assembler line.  This
 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.