.align/multiple .set bug
Tue Jul 20 12:17:00 GMT 2004
> .macro list_entry
> .int _start+link
> .set link,.-_start
> .set link,0
> .balign 4
> At any rate, this should produce a list of 8 32-bit values, each being
> the address of the previous value. I.e. 0, 4, 8, ... 0x18, 0x1c.
Note - if you really wanted that, then your macro should have been this:
.int _start + link
.set link,(. - _start) - 4
since you want "link" to store the offset to the ".int" instruction
which you have just generated. Anyway...
> Instead, the first time the symbol is set after the .balign pseudo-op,
> it gets some unexpected value.
> My best guess at the moment is that the alignment directives reset
the > current location counter to zero, or something like that.
It is actually quite complicated, but effectively yes, this is what is
happening. There is a relatively easy workaround for the problem
however - local labels. Try this version of your test code:
.int 1b - 4
I added the "nop" to demonstrate that the generated list addresses
really do refer back to the previous list entry and not just the
previous instruction of any kind.
This file produces the following disassembly:
0: ff ff ff fc fnmsub f31,f31,f31,f31
4: 00 00 00 00 .long 0x0
8: 00 00 00 04 .long 0x4
c: 00 00 00 08 .long 0x8
10: 60 00 00 00 nop
14: 00 00 00 0c .long 0xc
18: 00 00 00 14 .long 0x14
1c: 00 00 00 18 .long 0x18
20: 00 00 00 1c .long 0x1c
More information about the Binutils