[lld] r240217 - COFF: Fix common symbol alignment.
Rui Ueyama
ruiu at google.com
Sat Jun 20 00:25:45 PDT 2015
Author: ruiu
Date: Sat Jun 20 02:25:45 2015
New Revision: 240217
URL: http://llvm.org/viewvc/llvm-project?rev=240217&view=rev
Log:
COFF: Fix common symbol alignment.
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/test/COFF/common.test
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=240217&r1=240216&r2=240217&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Sat Jun 20 02:25:45 2015
@@ -16,6 +16,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
using namespace llvm;
using namespace llvm::object;
@@ -169,10 +170,9 @@ SectionRef SectionChunk::getSectionRef()
}
CommonChunk::CommonChunk(const COFFSymbolRef S) : Sym(S) {
- // Alignment is a section attribute, but common symbols don't
- // belong to any section. How do we know common data alignments?
- // Needs investigating. For now, we set a large number as an alignment.
- Align = 16;
+ // 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()));
}
uint32_t CommonChunk::getPermissions() const {
Modified: lld/trunk/test/COFF/common.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/common.test?rev=240217&r1=240216&r2=240217&view=diff
==============================================================================
--- lld/trunk/test/COFF/common.test (original)
+++ lld/trunk/test/COFF/common.test Sat Jun 20 02:25:45 2015
@@ -4,7 +4,7 @@
# Operands of B8 (MOV EAX) are common symbols
CHECK: 3000: b8 00 10 00 40
-CHECK: 3005: b8 10 10 00 40
+CHECK: 3005: b8 04 10 00 40
CHECK: 300a: b8 20 10 00 40
CHECK: 300f: b8 60 10 00 40
-CHECK: 3014: b8 70 10 00 40
+CHECK: 3014: b8 80 10 00 40
More information about the llvm-commits
mailing list