This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH][GAS/ARM] Better handling of difference between a symbol and an undefined symbol.
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 17 Mar 2011 21:29:01 +1030
- Subject: Re: [PATCH][GAS/ARM] Better handling of difference between a symbol and an undefined symbol.
- References: <4CA132F7.8020803@gmail.com> <AANLkTi=LnBj7U9V3PCrtUCoHj0QPV6d2VAKOwWJMw9T9@mail.gmail.com> <4CA1465D.30105@gmail.com> <AANLkTimewc4r=wh=ACmMJYkNgHcaiYWjM_Qe8xL+LKo2@mail.gmail.com> <AANLkTimpYE-k0c+LC2_AjgrGJ4XNRLypfSEYENU=jr4X@mail.gmail.com> <4CA1682D.8080500@gmail.com> <20100928041456.GU16376@bubble.grove.modra.org> <AANLkTinddt6Or0wcCN3Gh4U22C4QzwYoBDXA0S_CH3n6@mail.gmail.com> <20100929064955.GY16376@bubble.grove.modra.org> <AANLkTinnTc_Fathg_7SEhACBae3qNA8+ZoMPOmXJ-18e@mail.gmail.com>
This patch cures PR 12569 by simply removing the assert in
get_known_segmented_expression, and allowing expr_section in do_org.
A cop out, but it was proving difficult to properly set expression
symbol sections as other places in gas assumed that a symbol in the
absolute section could be resolved early. Besides, prior to the patch
that introduced this regression all sorts of section nastiness could
have hidden in expression symbols anyway.
PR 12569
* expr.c (operand): Correct passing of "mode" to expr.
* read.c (do_org): Allow expr_section.
(get_known_segmented_expression): Don't assert anything about the
segment.
Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.89
diff -u -p -r1.89 expr.c
--- gas/expr.c 4 Dec 2010 00:19:19 -0000 1.89
+++ gas/expr.c 17 Mar 2011 08:41:31 -0000
@@ -1,6 +1,6 @@
/* expr.c -operands, expressions-
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -959,10 +959,7 @@ operand (expressionS *expressionP, enum
#endif
case '(':
/* Didn't begin with digit & not a name. */
- if (mode != expr_defer)
- segment = expression (expressionP);
- else
- segment = deferred_expression (expressionP);
+ segment = expr (0, expressionP, mode);
/* expression () will pass trailing whitespace. */
if ((c == '(' && *input_line_pointer != ')')
|| (c == '[' && *input_line_pointer != ']'))
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.169
diff -u -p -r1.169 read.c
--- gas/read.c 15 Feb 2011 18:01:07 -0000 1.169
+++ gas/read.c 17 Mar 2011 08:41:34 -0000
@@ -1,7 +1,7 @@
/* read.c - read a source file -
Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010 Free Software Foundation, Inc.
+ 2010, 2011 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -2653,7 +2653,9 @@ s_mri (int ignore ATTRIBUTE_UNUSED)
static void
do_org (segT segment, expressionS *exp, int fill)
{
- if (segment != now_seg && segment != absolute_section)
+ if (segment != now_seg
+ && segment != absolute_section
+ && segment != expr_section)
as_bad (_("invalid segment \"%s\""), segment_name (segment));
if (now_seg == absolute_section)
@@ -5416,9 +5418,9 @@ get_segmented_expression (expressionS *e
static segT
get_known_segmented_expression (expressionS *expP)
{
- segT retval;
+ segT retval = get_segmented_expression (expP);
- if ((retval = get_segmented_expression (expP)) == undefined_section)
+ if (retval == undefined_section)
{
/* There is no easy way to extract the undefined symbol from the
expression. */
@@ -5432,8 +5434,7 @@ get_known_segmented_expression (expressi
expP->X_op = O_constant;
expP->X_add_number = 0;
}
- know (retval == absolute_section || SEG_NORMAL (retval));
- return (retval);
+ return retval;
}
char /* Return terminator. */
--
Alan Modra
Australia Development Lab, IBM