public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* another problem with m68k-elf
@ 2001-05-24  3:05 pjak
  2001-05-24 16:59 ` amodra
  0 siblings, 1 reply; 8+ messages in thread
From: pjak @ 2001-05-24  3:05 UTC (permalink / raw)
  To: binutils; +Cc: pjak

Hi,

the problems I had a few days ago seem to be fixed,
but now I have another problem with binutils (cvs),
target m68k-elf:

The code

x1:
  .space 16
  .set x2,.-x1

  .space x2

used to work, but now this produces an error message:

"Error: .space specifies non-absolute value"

Is this a bug or can I no longer use this contruct?

Thanks in advance,

Peter Jakubek
pjak@snafu.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: another problem with m68k-elf
@ 2001-05-24  3:19     ` pjak
  2001-05-25  3:05       ` finalize_syms for non-bfd amodra
  0 siblings, 1 reply; 8+ messages in thread
From: pjak @ 2001-05-24  3:19 UTC (permalink / raw)
  To: binutils; +Cc: pjak

pjak@snafu.de wrote:
> 
> Hi,
> 
> the problems I had a few days ago seem to be fixed,
> but now I have another problem with binutils (cvs),
> target m68k-elf:
> 
> The code
> 
> x1:
>   .space 16
>   .set x2,.-x1
> 
>   .space x2
> 
> used to work, but now this produces an error message:
> 
> "Error: .space specifies non-absolute value"
> 
> Is this a bug or can I no longer use this contruct?
> 

Ooops,

the above code did not even assemble with older (2.9.4) 
versions of gas.

However this worked (with -M option):

x1:
  ds.b 4
x1l: equ *-x1
  ds.b x1l

But does not assemble with the current cvs version.

Sorry for the confusion,

Peter Jakubek
pjak@snafu.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: another problem with m68k-elf
  2001-05-24  3:05 another problem with m68k-elf pjak
@ 2001-05-24 16:59 ` amodra
  2001-05-24 18:56   ` amodra
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-05-24 16:59 UTC (permalink / raw)
  To: pjak; +Cc: binutils

On Thu, May 24, 2001 at 12:05:29PM +0100, pjak@snafu.de wrote:
> x1:
>   .space 16
>   .set x2,.-x1
> 
>   .space x2
>[snip] 
> "Error: .space specifies non-absolute value"

We can make this work fairly easily.

gas/ChangeLog
	* expr.c (expr): Set return value to absolute_section for
	subtractive operations on symbols within a segment.
	* read.c (pseudo_set): Set segment for complex expressions.

-- 
Alan Modra

Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.33
diff -u -p -r1.33 expr.c
--- expr.c	2001/05/22 10:23:48	1.33
+++ expr.c	2001/05/24 23:10:54
@@ -1862,6 +1862,19 @@ expr (rankarg, resultP)
 	    resultP->X_add_number += right.X_add_number;
 	  else if (op_left == O_subtract)
 	    resultP->X_add_number -= right.X_add_number;
+	  if (retval == rightseg
+	      && (op_left == O_subtract
+		  || op_left == O_eq
+		  || op_left == O_ne
+		  || op_left == O_lt
+		  || op_left == O_le
+		  || op_left == O_ge
+		  || op_left == O_gt))
+	    {
+	      /* For subtractive operations on symbols within a
+		 segment, the result will absolute.  */
+	      retval = absolute_section;
+	    }
 	}
       else
 	{
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.37
diff -u -p -r1.37 read.c
--- read.c	2001/05/14 22:37:47	1.37
+++ read.c	2001/05/24 23:11:10
@@ -3151,6 +3151,7 @@ pseudo_set (symbolP)
      symbolS *symbolP;
 {
   expressionS exp;
+  segT seg;
 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
   int ext;
 #endif /* OBJ_AOUT or OBJ_BOUT */
@@ -3160,7 +3161,7 @@ pseudo_set (symbolP)
   ext = S_IS_EXTERNAL (symbolP);
 #endif /* OBJ_AOUT or OBJ_BOUT */
 
-  (void) expression (&exp);
+  seg = expression (&exp);
 
   if (exp.X_op == O_illegal)
     as_bad (_("illegal expression; zero assumed"));
@@ -3236,9 +3237,9 @@ pseudo_set (symbolP)
       break;
 
     default:
-      /* The value is some complex expression.
-	 FIXME: Should we set the segment to anything?  */
+      /* The value is some complex expression.  */
       symbol_set_value_expression (symbolP, &exp);
+      S_SET_SEGMENT (symbolP, seg);
       break;
     }
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: another problem with m68k-elf
  2001-05-24 16:59 ` amodra
@ 2001-05-24 18:56   ` amodra
  2001-05-24  3:19     ` pjak
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-05-24 18:56 UTC (permalink / raw)
  To: pjak; +Cc: binutils

On Fri, May 25, 2001 at 09:35:57AM +0930, Alan Modra wrote:
> On Thu, May 24, 2001 at 12:05:29PM +0100, pjak@snafu.de wrote:
> > x1:
> >   .space 16
> >   .set x2,.-x1
> > 
> >   .space x2
> >[snip] 
> > "Error: .space specifies non-absolute value"
> 
> We can make this work fairly easily.

No, we can't.  This breaks other places in the assembler that assume
a symbol in absolute_section can be evaluated at any time.  I should
have known...  Reverting until I figure this mess out.

> gas/ChangeLog
> 	* expr.c (expr): Set return value to absolute_section for
> 	subtractive operations on symbols within a segment.
> 	* read.c (pseudo_set): Set segment for complex expressions.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* finalize_syms for non-bfd
  2001-05-24  3:19     ` pjak
@ 2001-05-25  3:05       ` amodra
       [not found]         ` <3B0E57D7.2073@snafu.de>
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-05-25  3:05 UTC (permalink / raw)
  To: binutils; +Cc: pjak

This change seems to be the easiest and least intrusive way of fixing
non-bfd targets affected by the change to symbol resolution.  It also
happens to fix both problems mentioned in
http://sources.redhat.com/ml/binutils/2001-05/msg00419.html

gas/ChangeLog
	* symbols.c (resolve_symbol_value): Always set segment, even when
	not finalizing symbol value.

-- 
Alan Modra

Index: gas/symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.23
diff -u -p -r1.23 symbols.c
--- symbols.c	2001/05/24 23:44:06	1.23
+++ symbols.c	2001/05/25 09:32:12
@@ -942,7 +942,7 @@ resolve_symbol_value (symp)
 	    {
 	      if (finalize_syms)
 		{
-		  S_SET_SEGMENT (symp, S_GET_SEGMENT (add_symbol));
+		  final_seg = S_GET_SEGMENT (add_symbol);
 		  symp->sy_value.X_op = O_symbol;
 		  symp->sy_value.X_add_symbol = add_symbol;
 		  symp->sy_value.X_add_number = final_val;
@@ -1146,18 +1146,18 @@ resolve_symbol_value (symp)
     }
 
   if (finalize_syms)
-    {
-      S_SET_VALUE (symp, final_val);
+    S_SET_VALUE (symp, final_val);
 
+exit_dont_set_value:
+  /* Always set the segment, even if not finalizing the value.
+     The segment is used to determine whether a symbol is defined.  */
 #if defined (OBJ_AOUT) && ! defined (BFD_ASSEMBLER)
-      /* The old a.out backend does not handle S_SET_SEGMENT correctly
-         for a stab symbol, so we use this bad hack.  */
-      if (final_seg != S_GET_SEGMENT (symp))
+  /* The old a.out backend does not handle S_SET_SEGMENT correctly
+     for a stab symbol, so we use this bad hack.  */
+  if (final_seg != S_GET_SEGMENT (symp))
 #endif
-	S_SET_SEGMENT (symp, final_seg);
-    }
+    S_SET_SEGMENT (symp, final_seg);
 
-exit_dont_set_value:
   /* Don't worry if we can't resolve an expr_section symbol.  */
   if (finalize_syms)
     {

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: finalize_syms for non-bfd
       [not found]         ` <3B0E57D7.2073@snafu.de>
@ 2001-05-26  5:49           ` amodra
       [not found]             ` <3B0FED8B.4E64@snafu.de>
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-05-26  5:49 UTC (permalink / raw)
  To: Peter Jakubek; +Cc: binutils

On Fri, May 25, 2001 at 03:02:15PM +0200, Peter Jakubek wrote:
> 
> results in "error5m.s:20: Warning: .space or .fill with negative value,
> ignored".

This code
      growth = (fragP->fr_address + amount
                - fragP->fr_next->fr_address);
was subtracting an address that hadn't yet been adjusted by "strech"
from one that had.  Harmless enough in most cases, because the next
time around the relax loop "stretch" settles to zero, and we get the
correct value.

> -			as_warn (_(".space or .fill with negative value, ignored"));
> +			as_warn_where (fragP->fr_file, fragP->fr_line, _(".space or .fill
> with negative value, ignored"));

Thanks.  I'll install this, and fix some similar cases while I'm at it.

	* write.c (relax_segment <rs_space>): Calculate growth using
	addresses before stretch.  Prevent repeated error messages.
	From Peter Jakubek  <pjak@snafu.de>
	Use as_bad_where and as_warn_where to pinpoint errors.

-- 
Alan Modra

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.35
diff -u -p -r1.35 write.c
--- write.c	2001/05/24 23:33:00	1.35
+++ write.c	2001/05/26 12:31:58
@@ -2241,8 +2241,9 @@ relax_segment (segment_frag_root, segmen
 
 	    if (offset % fragP->fr_var != 0)
 	      {
-		as_bad (_("alignment padding (%lu bytes) not a multiple of %ld"),
-			(unsigned long) offset, (long) fragP->fr_var);
+		as_bad_where (fragP->fr_file, fragP->fr_line,
+			      _("alignment padding (%lu bytes) not a multiple of %ld"),
+			      (unsigned long) offset, (long) fragP->fr_var);
 		offset -= (offset % fragP->fr_var);
 	      }
 
@@ -2353,10 +2354,11 @@ relax_segment (segment_frag_root, segmen
 			    {
 			      char buf[50];
 			      sprint_value (buf, (addressT) lie->addnum);
-			      as_warn (_(".word %s-%s+%s didn't fit"),
-				       S_GET_NAME (lie->add),
-				       S_GET_NAME (lie->sub),
-				       buf);
+			      as_warn_where (fragP->fr_file, fragP->fr_line,
+					     _(".word %s-%s+%s didn't fit"),
+					     S_GET_NAME (lie->add),
+					     S_GET_NAME (lie->sub),
+					     buf);
 			    }
 			  lie->added = 1;
 			  if (fragP->fr_subtype == 0)
@@ -2451,6 +2453,7 @@ relax_segment (segment_frag_root, segmen
 		}
 
 	      case rs_space:
+		growth = 0;
 		if (symbolP)
 		  {
 		    offsetT amount;
@@ -2459,19 +2462,22 @@ relax_segment (segment_frag_root, segmen
 		    if (symbol_get_frag (symbolP) != &zero_address_frag
 			|| S_IS_COMMON (symbolP)
 			|| ! S_IS_DEFINED (symbolP))
-		      as_bad_where (fragP->fr_file, fragP->fr_line,
-				    _(".space specifies non-absolute value"));
-		    if (amount < 0)
+		      {
+			as_bad_where (fragP->fr_file, fragP->fr_line,
+				      _(".space specifies non-absolute value"));
+			/* Prevent repeat of this error message.  */
+			fragP->fr_symbol = 0;
+		      }
+		    else if (amount < 0)
 		      {
-			as_warn (_(".space or .fill with negative value, ignored"));
-			amount = 0;
+			as_warn_where (fragP->fr_file, fragP->fr_line,
+				       _(".space or .fill with negative value, ignored"));
 			fragP->fr_symbol = 0;
 		      }
-		    growth = (fragP->fr_address + amount
-			      - fragP->fr_next->fr_address);
+		    else
+		      growth = (was_address + amount
+				- fragP->fr_next->fr_address);
 		  }
-		else
-		  growth = 0;
 		break;
 
 	      case rs_machine_dependent:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: finalize_syms for non-bfd
       [not found]             ` <3B0FED8B.4E64@snafu.de>
@ 2001-05-27  5:16               ` amodra
  2001-05-27 13:26                 ` Peter Jakubek
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-05-27  5:16 UTC (permalink / raw)
  To: Peter Jakubek; +Cc: binutils

On Sat, May 26, 2001 at 07:53:15PM +0200, Peter Jakubek wrote:
> 
> The mri variant works now, with and without listing:
> 
> This should be the equivalent code using the alternative syntax:
> 
>   .mri 0
>   .text
> x1:  .space 2
>      .set x1l,.-x1
> x2:  .space 4
>      .set x2l,.-x2
> x3:  .space x1l
>      .space x2l
>      .space 4
>      .set x3l,.-x3
> x4:  .space x1l
>      .space 4
>      .set x4l,.-x4
> s1:  .space 4
>      .set s1l,.-s1
> s2:  .space 4
>      .space s1l
>      .set s2l,.-s2
> s3:  .space 4
>      .space s1l
>      .space s2l
>      .set s3l,.-s3
> 
> This seems to assemble as long as I do *not* enable listings.
> With the -a option this produces error messages:
> 
> error5g.s:7: Error: .space specifies non-absolute value
> error5g.s:8: Error: .space specifies non-absolute value
> error5g.s:11: Error: .space specifies non-absolute value
> error5g.s:17: Error: .space specifies non-absolute value
> error5g.s:20: Error: .space specifies non-absolute value
> error5g.s:21: Error: .space specifies non-absolute value
> 
> How come?

gas/read.c:2776 messes up gas/write.c:2462.  I think this patch will
work now that resolve_symbol_value sets the symbol segment even when
not fully resolving.

gas/ChangeLog
	* write.c (relax_segment <rs_space>): Check the section of a
	symbol to determine whether it is absolute rather than comparing
	its frag against zero_address_frag as listings play tricks with
	frags.

-- 
Alan Modra
 
Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.36
diff -u -p -r1.36 write.c
--- write.c	2001/05/26 12:45:15	1.36
+++ write.c	2001/05/27 11:38:19
@@ -2459,7 +2459,7 @@ relax_segment (segment_frag_root, segmen
 		    offsetT amount;
 
 		    amount = S_GET_VALUE (symbolP);
-		    if (symbol_get_frag (symbolP) != &zero_address_frag
+		    if (S_GET_SEGMENT (symbolP) != absolute_section
 			|| S_IS_COMMON (symbolP)
 			|| ! S_IS_DEFINED (symbolP))
 		      {

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: finalize_syms for non-bfd
  2001-05-27  5:16               ` amodra
@ 2001-05-27 13:26                 ` Peter Jakubek
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Jakubek @ 2001-05-27 13:26 UTC (permalink / raw)
  To: binutils; +Cc: amodra

amodra@one.net.au wrote:
> 
> gas/read.c:2776 messes up gas/write.c:2462.  I think this patch will
> work now that resolve_symbol_value sets the symbol segment even when
> not fully resolving.
>[snip]

Thanks Alan,

everything seems to work now!

Peter Jakubek
pjak@snafu.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-05-27 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-24  3:05 another problem with m68k-elf pjak
2001-05-24 16:59 ` amodra
2001-05-24 18:56   ` amodra
2001-05-24  3:19     ` pjak
2001-05-25  3:05       ` finalize_syms for non-bfd amodra
     [not found]         ` <3B0E57D7.2073@snafu.de>
2001-05-26  5:49           ` amodra
     [not found]             ` <3B0FED8B.4E64@snafu.de>
2001-05-27  5:16               ` amodra
2001-05-27 13:26                 ` Peter Jakubek

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).