public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* gas fixup problem?
@ 1995-06-21 16:57 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 1995-06-21 16:57 UTC (permalink / raw)
  To: gas2

/usr/i486-linux/bin/as zzz.s; nm a.out
00000000 t L0
00000006 t L1
00000002 t L2		!!!!!!!!!
00000006 t L3
00000015 t L4
00000094 t L5

 --------------------zzz.s----------------
	.text
L0:
	jz L5
L1:
L2:
L3:
	.space -(L2 - L0 + 0x7f) & (16-1), 0x90

L4:
	.space 0x7f, 0x90
L5:
 -----------------------------------------

The idea of the .space here is to align L5, given we know how much
code is between the .space and L5.  Maybe this bug is just related to
.space, but if it's something to do with expression evaluation, then
it is a more serious one.  I'll see if I can fix it myself, but my
time is rather limited at the moment.  Maybe someone else will get
curious as to what is wrong here?


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

* Re: gas fixup problem?
       [not found] <no.id>
@ 1995-06-24  3:51 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 1995-06-24  3:51 UTC (permalink / raw)
  To: gas2

> 
> /usr/i486-linux/bin/as zzz.s; nm a.out
> 00000000 t L0
> 00000006 t L1
> 00000002 t L2		!!!!!!!!!
> 00000006 t L3
> 00000015 t L4
> 00000094 t L5
> 
>  --------------------zzz.s----------------
> 	.text
> L0:
> 	jz L5
> L1:
> L2:
> L3:
> 	.space -(L2 - L0 + 0x7f) & (16-1), 0x90
> 
> L4:
> 	.space 0x7f, 0x90
> L5:
>  -----------------------------------------
> 
> The idea of the .space here is to align L5, given we know how much
> code is between the .space and L5.  Maybe this bug is just related to
> .space, but if it's something to do with expression evaluation, then
> it is a more serious one.  I'll see if I can fix it myself, but my
> time is rather limited at the moment.  Maybe someone else will get
> curious as to what is wrong here?
> 
A bit more info.  The problem seems to be caused inside S_GET_VALUE()
in write.c around line 1937.  S_GET_VALUE tries to evaluate the
expression, and in so doing resolves L2 to be equal to 2, correct for
the first time round when the "jz" is assumed to be a short
instruction.  When gas decide that the "jz" needs to be a long branch
occupying 6 bytes, the value of L2 is marked as resolved so isn't
adjusted.
I'm not sure I have the time to figure out how all the gas internals
work, so a fix from me will take a while...

.org also exhibits the same sort of behaviour with
-------------------------------
        .text
Z0:
        jz Z9
Z1:
Z2:
        .org (15 & -(Z2 - Z0)) + .
Z5:
        .space 0x7f, 0x90
Z9:
-------------------------------
similarly giving wrong values for Z2

The slightly more contrived
-------------------------------
        .text
Z0:
        jz Z9
Z1:
Z2:
        .org (Z2 - Z0 + 1) + .
Z5:
        .space 0x7f, 0x90
Z9:
-------------------------------
bombs with
z1.s: Assembler messages:
z1.s:9: Error: attempt to .org/.space backwards? (-3)
z1.s:9: Internal error!
Assertion failure in write_contents at write.c line 924.
Please report this bug.

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

end of thread, other threads:[~1995-06-24  3:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-21 16:57 gas fixup problem? Alan Modra
     [not found] <no.id>
1995-06-24  3:51 ` Alan Modra

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