From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17523 invoked by alias); 5 Mar 2011 15:32:57 -0000 Received: (qmail 17514 invoked by uid 22791); 5 Mar 2011 15:32:56 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 05 Mar 2011 15:32:52 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 05 Mar 2011 07:32:50 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by orsmga001.jf.intel.com with ESMTP; 05 Mar 2011 07:32:50 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id E5831180B25; Sat, 5 Mar 2011 07:32:49 -0800 (PST) Date: Sat, 05 Mar 2011 15:32:00 -0000 From: "H.J. Lu" To: binutils@sourceware.org Cc: Alan Modra Subject: PATCH: Mention symbol name in non-constant .size expression Message-ID: <20110305153249.GA32480@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00078.txt.bz2 Hi, The error message in non-constant .size expression doesn't show the correct line number nor symbol names. It is hard to get the line number right. This patch displays symbol name in non-constant .size expression. It will help users identify the assembly code bugs. OK to install? Thanks. H.J. --- diff --git a/gas/ChangeLog.intel b/gas/ChangeLog.intel index 8eb236d..38ee6a2 100644 --- a/gas/ChangeLog.intel +++ b/gas/ChangeLog.intel @@ -1,3 +1,8 @@ +2011-03-05 H.J. Lu + + * config/obj-elf.c (elf_frob_symbol): Mention symbol name in + non-constant .size expression. + 2010-03-08 Alan Modra PR gas/11356 diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 969a509..d43409a 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1879,6 +1879,7 @@ void elf_frob_symbol (symbolS *symp, int *puntp) { struct elf_obj_sy *sy_obj; + expressionS *size; #ifdef NEED_ECOFF_DEBUG if (ECOFF_DEBUGGING) @@ -1887,13 +1888,50 @@ elf_frob_symbol (symbolS *symp, int *puntp) sy_obj = symbol_get_obj (symp); - if (sy_obj->size != NULL) + size = sy_obj->size; + if (size != NULL) { - if (resolve_expression (sy_obj->size) - && sy_obj->size->X_op == O_constant) - S_SET_SIZE (symp, sy_obj->size->X_add_number); + if (resolve_expression (size) + && size->X_op == O_constant) + S_SET_SIZE (symp, size->X_add_number); else - as_bad (_(".size expression does not evaluate to a constant")); + { + const char *op_name = NULL; + const char *add_name = NULL; + + if (size->X_op == O_subtract) + { + op_name = S_GET_NAME (size->X_op_symbol); + add_name = S_GET_NAME (size->X_add_symbol); + if (strcmp (op_name, FAKE_LABEL_NAME) == 0) + op_name = NULL; + if (strcmp (add_name, FAKE_LABEL_NAME) == 0) + add_name = NULL; + + if (op_name && add_name) + as_bad (_(".size expression with symbols `%s' and `%s' " + "does not evaluate to a constant"), + op_name, add_name); + else + { + const char *name; + + if (op_name) + name = op_name; + else if (add_name) + name = add_name; + else + name = NULL; + + if (name) + as_bad (_(".size expression with symbol `%s' " + "does not evaluate to a constant"), name); + } + } + + if (!op_name && !add_name) + as_bad (_(".size expression does not evaluate to a constant")); + } free (sy_obj->size); sy_obj->size = NULL; } diff --git a/gas/testsuite/ChangeLog.intel b/gas/testsuite/ChangeLog.intel index 47d7048..602730c 100644 --- a/gas/testsuite/ChangeLog.intel +++ b/gas/testsuite/ChangeLog.intel @@ -1,3 +1,7 @@ +2011-03-05 H.J. Lu + + * gas/elf/bad-size.err: Updated. + 2010-03-08 H.J. Lu PR gas/9966 diff --git a/gas/testsuite/gas/elf/bad-size.err b/gas/testsuite/gas/elf/bad-size.err index 5e01ef2..a5bfc31 100644 --- a/gas/testsuite/gas/elf/bad-size.err +++ b/gas/testsuite/gas/elf/bad-size.err @@ -1,2 +1,2 @@ .*bad-size\.s: Assembler messages: -.*bad-size\.s:6: Error: .* +.*bad-size\.s:6: Error:.*`_test_nop'.*