.align 0

I have several assembly files in a testsuite that use, ".align 0". I found a reference to, ".align 0" in ARM's elf.h that says .align 0 is redundant and gas treats this as align 2.

Should the llvm-mc follow this convention?

Hi Sid,

It seems Apple’s assembler used to treat .align 0 differently:

https://developer.apple.com/library/mac/documentation/developertools/Reference/Assembler/040-Assembler_Directives/asm_directives.html

If this is still the case, than we should have an option for what to do in this case, maybe defaulting based on the triple?

cheers,
–renato

Apple’s assembler does use power-of-two for .align. I believe binutils does as well. I suspect the header file comment is in error and what’s actually happening is that the section in question has a minimum alignment on the system(s) in question, and so it just looks like it’s redundant. That is, I doubt we need to do anything here.

-Jim

".align 0" triggers the following error:

a.s:2:8: error: alignment must be a power of 2
.align 0
        ^
In this case would it be reasonable to query the target for a default
or minimum value? Only targets not implementing this would error out.

Thanks,

I do not see that behavior on Darwin with either the old assembler or the integrated assembler:

enkidu: ~/tmp $ cat t.s
.align 0

enkidu: ~/tmp $ as t.s
enkidu: ~/tmp $ clang -c t.s

Yeah, it looks like a combination of target and platform logic determines how the value is interpreted. It’s x86 ELF that’s the outlier here, expecting a value in number of bytes.

There is no mention of the special case for zero in https://sourceware.org/binutils/docs/as/Align.html#Align. From that, I would argue that the diagnostic is correct and the test cases are in error. If gas actually does default to ‘2’ for a specified value of zero, that seems really terrible and an error not to be repeated.

-Jim