1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[MC/ELF] Accept zero for .align directive

.align directive refuses alignment 0 -- a comment in the code hints this is
done for GNU as compatibility, but it seems GNU as accepts .align 0
(and silently rounds up alignment to 1).

Differential Revision:	 http://reviews.llvm.org/D12682

llvm-svn: 247048
This commit is contained in:
Davide Italiano 2015-09-08 18:59:47 +00:00
parent 708eee92f1
commit d9617dc535
2 changed files with 9 additions and 1 deletions

View File

@ -2706,7 +2706,11 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
Alignment = 1ULL << Alignment; Alignment = 1ULL << Alignment;
} else { } else {
// Reject alignments that aren't a power of two, for gas compatibility. // Reject alignments that aren't either a power of two or zero,
// for gas compatibility. Alignment of zero is silently rounded
// up to one.
if (Alignment == 0)
Alignment = 1;
if (!isPowerOf2_64(Alignment)) if (!isPowerOf2_64(Alignment))
Error(AlignmentLoc, "alignment must be a power of 2"); Error(AlignmentLoc, "alignment must be a power of 2");
} }

4
test/MC/ELF/align-zero.s Normal file
View File

@ -0,0 +1,4 @@
// Test that an alignment of zero is accepted.
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o -
.align 0