[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] binutils problem ??



Hello, Alan.

Can someone compile this test app....

test:
	.word	3
test2:
	.align	2
test3:
	.word	5

build with....

as -o test.o test.S

and then run
nm test.o

With the current binutils from Vincent I get....

00000000 t test
00000002 t test2
00000002 t test3

but with the old binutils I get...

00000000 t test
00000002 t test2
00000004 t test3

Can anyone confirm ??

I confirm.

The semantics of the .align directive are different between assemblers and platforms, it must be considered as unportable. The meaning of .align is even different between gas versions.

To solve this issue, gas introduced 2 new directives :

.balign     takes an absolute value in bytes
.p2align    takes a power of 2

So ".balign 8" is the same as ".p2align 3", the next data will be aligned on 8 bytes.

".even" is portable, it is the same as ".balign 2"

Depending on assemblers and platforms, ".align" behaves like ".balign" or ".p2align", so it is unportable.

The standard gas behaviour is like this:
- on a.out targets, .align is like .p2align
- on ELF targets, .align is like .balign
- on some specific platforms it is different

The old binutils 2.13 for MiNT use the default gas behaviour, so since we use a.out object files, .align behaves like .p2align and takes a power of 2.

My current binutils patch use the standard (?) Atari behaviour, .align takes an absolute value.

This .align behaviour is the only functional change I made in the binutils, and I have been considering reverting it for some time (any remark is welcome).

Today I consider that .align is unsafe and we must use .balign instead. So if no one uses .align, its behaviour is not important, and we should keep the gas default. But beware, if one day we use ELF object files, the semantics of .align will change. Another good reason to not use .align.

And beware, the maximum alignment supported by our toolchain is 4 bytes, it will be honored in recent OS versions (like TOS 4.x and FreeMiNT) but not in older TOS versions like 1.62.

No mystery here.

--
Vincent Rivière