Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -184,6 +184,10 @@ if (Flags & SHF_WRITE) fatal(getFilename(this) + ": writable SHF_MERGE section is not supported"); uintX_t EntSize = Sec.sh_entsize; + + // In a FreeBSD/i386 world many objects have SHF_MERGE with sh_entsize == 0. + if (!EntSize && Config->EMachine == EM_386) + return false; if (!EntSize || Sec.sh_size % EntSize) fatal(getFilename(this) + ": SHF_MERGE section size must be a multiple of sh_entsize"); Index: test/ELF/invalid-elf.test =================================================================== --- test/ELF/invalid-elf.test +++ test/ELF/invalid-elf.test @@ -28,6 +28,10 @@ # RUN: FileCheck --check-prefix=INVALID-SHENTSIZE-ZERO %s # INVALID-SHENTSIZE-ZERO: SHF_MERGE section size must be a multiple of sh_entsize +## In a FreeBSD/i386 world many objects have SHF_MERGE with sh_entsize == 0. +# RUN: ld.lld %p/Inputs/invalid-shentsize-zero-i386.elf -o %t2 +# RUN: llvm-readobj %t2 > /dev/null + # 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