COFF: Set non-1 alignment to common chunks.
I don't know what the right thing to do here, but at least 1 does
not seem like a correct value. If we do not align common chunks at
all, a small program which calls puts() from global dtors crashes
mysteriously in a kernel32's function.
I believe the crash was caused by symbols overlapping each other,
and my guess is that alignment has something to do with that, but
I am not 100% sure. Needs investigating.
llvm-svn: 239280
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index e485936..ecd5b41 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -151,6 +151,13 @@
return SectionRef(Ref, File->getCOFFObj());
}
+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;
+}
+
uint32_t CommonChunk::getPermissions() const {
return IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE;