Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -212,6 +212,8 @@ uint8_t StOther, uint8_t Type, InputFile *File) : Defined(SymbolBody::DefinedCommonKind, N, StOther, Type), Alignment(Alignment), Size(Size) { + if (Alignment == 0) + fatal(getFilename(File) + ": common symbol '" + N + "' alignment is 0"); this->File = File; } Index: test/ELF/invalid/common-symbol-alignment.s =================================================================== --- test/ELF/invalid/common-symbol-alignment.s +++ test/ELF/invalid/common-symbol-alignment.s @@ -0,0 +1,6 @@ +# REQUIRES: x86 + +## common-symbol-alignment.elf contains common symbol with zero alignment. +# RUN: not ld.lld %S/Inputs/common-symbol-alignment.elf \ +# RUN: -o %t 2>&1 | FileCheck %s +# CHECK: common symbol 'bar' alignment is 0