From: Alan Modra Date: Fri, 18 Mar 2011 12:01:50 +0000 (+0000) Subject: * config/obj-elf.c (elf_frob_symbol): Report S_SET_SIZE symbol X-Git-Tag: binutils-2_21_1~143 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59be86c8036c1a73f3de741bfa47c2d2aec6840c;p=thirdparty%2Fbinutils-gdb.git * 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 * 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=. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 2c2ebf7fed5..ad3b55a4f97 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +2011-03-18 Alan Modra + + * 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 + * 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 PR 12569 diff --git a/gas/as.c b/gas/as.c index 8fe13e97149..380259c0284 100644 --- 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; diff --git a/gas/as.h b/gas/as.h index 7c163826d90..d993c74fe89 100644 --- 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 diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 969a5091e8e..54021fc1be8 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -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; } diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 6a3fc813041..c775e142f3c 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -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.