Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -148,7 +148,9 @@ if (Flags & SHF_WRITE) fatal("writable SHF_MERGE sections are not supported"); uintX_t EntSize = Sec.sh_entsize; - if (!EntSize || Sec.sh_size % EntSize) + if (!EntSize) + return false; + if (Sec.sh_size % EntSize) fatal("SHF_MERGE section size must be a multiple of sh_entsize"); // Don't try to merge if the aligment is larger than the sh_entsize and this Index: test/ELF/invalid-elf.test =================================================================== --- test/ELF/invalid-elf.test +++ test/ELF/invalid-elf.test @@ -24,10 +24,6 @@ # RUN: FileCheck --check-prefix=INVALID-SECTION-INDEX %s # INVALID-SECTION-INDEX: Invalid section index -# RUN: not ld.lld %p/Inputs/invalid-shentsize-zero.elf -o %t2 2>&1 | \ -# RUN: FileCheck --check-prefix=INVALID-SHENTSIZE-ZERO %s -# INVALID-SHENTSIZE-ZERO: SHF_MERGE section size must be a multiple of sh_entsize - # RUN: not ld.lld %p/Inputs/invalid-multiple-eh-relocs.elf -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-EH-RELOCS %s # INVALID-EH-RELOCS: multiple relocation sections to .eh_frame are not supported Index: test/ELF/merge-zero-size.s =================================================================== --- /dev/null +++ test/ELF/merge-zero-size.s @@ -0,0 +1,4 @@ +# RUN: ld.lld %p/Inputs/invalid-shentsize-zero.elf -o %t2 2>&1 | \ +# RUN: FileCheck -allow-empty %s +# CHECK-NOT: SHF_MERGE section size must be a multiple of sh_entsize +