[lld/COFF] Don't round alignment if it's already a power-of-two.
authorDavide Italiano <davide@freebsd.org>
Fri, 11 Nov 2016 02:53:48 +0000 (02:53 +0000)
committerDavide Italiano <davide@freebsd.org>
Fri, 11 Nov 2016 02:53:48 +0000 (02:53 +0000)
This matches link.exe behaviour.

Differential Revision:  https://reviews.llvm.org/D26372

llvm-svn: 286553

lld/COFF/Chunks.cpp
lld/test/COFF/common.test

index 90f1485..0c00f7c 100644 (file)
@@ -249,7 +249,7 @@ void SectionChunk::replace(SectionChunk *Other) {
 CommonChunk::CommonChunk(const COFFSymbolRef S) : Sym(S) {
   // Common symbols are aligned on natural boundaries up to 32 bytes.
   // This is what MSVC link.exe does.
-  Align = std::min(uint64_t(32), NextPowerOf2(Sym.getValue()));
+  Align = std::min(uint64_t(32), PowerOf2Ceil(Sym.getValue()));
 }
 
 uint32_t CommonChunk::getPermissions() const {
index d57ced4..007cfcf 100644 (file)
@@ -7,7 +7,7 @@
 # CHECK: 3005: b8 04 10 00 40
 # CHECK: 300a: b8 20 10 00 40
 # CHECK: 300f: b8 60 10 00 40
-# CHECK: 3014: b8 80 10 00 40
+# CHECK: 3014: b8 70 10 00 40
 
 --- !COFF
 header: