public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR12519 ELF .size expressions
Date: Fri, 25 Feb 2011 13:40:00 -0000	[thread overview]
Message-ID: <20110225134026.GC5959@bubble.grove.modra.org> (raw)

Fixes code handling ELF .size expressions that can't be evaluated
immediately for some reasone, for example if the .size directive was
given at the beginning of the function referencing a label at the end
of the function.  Also corrects a couple of errors in the testsuite
that the old .size code wrongly accepted.

gas/
	PR gas/12519
	* config/obj-elf.c (elf_frob_symbol): Properly handle size expression.
ld/testsuite/
	* ld-mn10300/i135409-3.s: Correct .size label reference.
	* ld-sh/sh64/stolib.s: Likewise.

Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.136
diff -u -p -r1.136 obj-elf.c
--- gas/config/obj-elf.c	18 Nov 2010 16:00:25 -0000	1.136
+++ gas/config/obj-elf.c	25 Feb 2011 13:27:51 -0000
@@ -1,6 +1,6 @@
 /* ELF object file format
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -1889,23 +1889,11 @@ elf_frob_symbol (symbolS *symp, int *pun
 
   if (sy_obj->size != NULL)
     {
-      switch (sy_obj->size->X_op)
-	{
-	case O_subtract:
-	  S_SET_SIZE (symp,
-		      (S_GET_VALUE (sy_obj->size->X_add_symbol)
-		       + sy_obj->size->X_add_number
-		       - S_GET_VALUE (sy_obj->size->X_op_symbol)));
-	  break;
-	case O_constant:
-	  S_SET_SIZE (symp,
-		      (S_GET_VALUE (sy_obj->size->X_add_symbol)
-		       + sy_obj->size->X_add_number));
-	  break;
-	default:
-	  as_bad (_(".size expression too complicated to fix up"));
-	  break;
-	}
+      if (resolve_expression (sy_obj->size)
+	  && 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"));
       free (sy_obj->size);
       sy_obj->size = NULL;
     }
Index: ld/testsuite/ld-mn10300/i135409-3.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mn10300/i135409-3.s,v
retrieving revision 1.1
diff -u -p -r1.1 i135409-3.s
--- ld/testsuite/ld-mn10300/i135409-3.s	13 Nov 2007 10:40:27 -0000	1.1
+++ ld/testsuite/ld-mn10300/i135409-3.s	25 Feb 2011 13:27:51 -0000
@@ -10,7 +10,7 @@ A:
 BOTTOM:
       .balign 0x8
       add     D0,D1
-      .size   _func, .-func
+      .size   _func, .-_func
 
       .data
 L001:
Index: ld/testsuite/ld-sh/sh64/stolib.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sh/sh64/stolib.s,v
retrieving revision 1.1
diff -u -p -r1.1 stolib.s
--- ld/testsuite/ld-sh/sh64/stolib.s	15 Oct 2003 06:23:55 -0000	1.1
+++ ld/testsuite/ld-sh/sh64/stolib.s	25 Feb 2011 13:27:51 -0000
@@ -4,4 +4,4 @@
 bar:
 	ptabs	r18, tr0
 	blink	tr0, r63
-	.Lfe_bar: .size bar,.Lfe_bar-X
+.Lfe_bar: .size bar,.Lfe_bar-bar

-- 
Alan Modra
Australia Development Lab, IBM

             reply	other threads:[~2011-02-25 13:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25 13:40 Alan Modra [this message]
2011-02-25 17:01 ` H.J. Lu

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=20110225134026.GC5959@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /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).