From mboxrd@z Thu Jan 1 00:00:00 1970 From: alan@spri.levels.unisa.edu.au (Alan Modra) To: gas2@cygnus.com Subject: Re: gas fixup problem? Date: Sat, 24 Jun 1995 03:51:00 -0000 Message-id: References: X-SW-Source: 1995/msg00126.html > > /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.