From c520e18ce067963f410a3f1dc685b9a27e1c1f17 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 11 Nov 2016 02:53:48 +0000 Subject: [PATCH] [lld/COFF] Don't round alignment if it's already a power-of-two. This matches link.exe behaviour. Differential Revision: https://reviews.llvm.org/D26372 llvm-svn: 286553 --- lld/COFF/Chunks.cpp | 2 +- lld/test/COFF/common.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index 90f1485..0c00f7c 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -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 { diff --git a/lld/test/COFF/common.test b/lld/test/COFF/common.test index d57ced4..007cfcf 100644 --- a/lld/test/COFF/common.test +++ b/lld/test/COFF/common.test @@ -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: -- 2.7.4