Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -45,6 +45,8 @@ Header(Hdr), File(File), Repl(this) { // The ELF spec states that a value of 0 means the section has // no alignment constraits. + if (Header->sh_addralign > UINT32_MAX) + fatal(getFilename(File) + ": section sh_addralign is too large"); Alignment = std::max(Header->sh_addralign, 1); } Index: test/ELF/invalid/section-alignment.s =================================================================== --- test/ELF/invalid/section-alignment.s +++ test/ELF/invalid/section-alignment.s @@ -0,0 +1,7 @@ +# REQUIRES: x86 + +## In current lld implementation, we do not accept sh_addralign +## larger than UINT32_MAX. +# RUN: not ld.lld %S/Inputs/section-alignment.elf \ +# RUN: -o %t 2>&1 | FileCheck %s +# CHECK: section sh_addralign is too large