[ELF] SHF_MERGE section with 0 entsize is not fatal

For now just treat such sections as non-mergeable.

Resubmit r263660 with test fix.

Differential Revision:     http://reviews.llvm.org/D18225

llvm-svn: 263664
This commit is contained in:
Ed Maste 2016-03-16 21:12:53 +00:00
parent 19c6159833
commit b321050a93
4 changed files with 7 additions and 5 deletions

View File

@ -148,7 +148,9 @@ template <class ELFT> static bool shouldMerge(const typename ELFT::Shdr &Sec) {
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

View File

@ -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

View File

@ -0,0 +1,4 @@
# RUN: ld.lld %p/Inputs/merge-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