Skip to content

Commit b321050

Browse files
committed
[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
1 parent 19c6159 commit b321050

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ template <class ELFT> static bool shouldMerge(const typename ELFT::Shdr &Sec) {
148148
if (Flags & SHF_WRITE)
149149
fatal("writable SHF_MERGE sections are not supported");
150150
uintX_t EntSize = Sec.sh_entsize;
151-
if (!EntSize || Sec.sh_size % EntSize)
151+
if (!EntSize)
152+
return false;
153+
if (Sec.sh_size % EntSize)
152154
fatal("SHF_MERGE section size must be a multiple of sh_entsize");
153155

154156
// Don't try to merge if the aligment is larger than the sh_entsize and this

lld/test/ELF/invalid-elf.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
# RUN: FileCheck --check-prefix=INVALID-SECTION-INDEX %s
2525
# INVALID-SECTION-INDEX: Invalid section index
2626

27-
# RUN: not ld.lld %p/Inputs/invalid-shentsize-zero.elf -o %t2 2>&1 | \
28-
# RUN: FileCheck --check-prefix=INVALID-SHENTSIZE-ZERO %s
29-
# INVALID-SHENTSIZE-ZERO: SHF_MERGE section size must be a multiple of sh_entsize
30-
3127
# RUN: not ld.lld %p/Inputs/invalid-multiple-eh-relocs.elf -o %t2 2>&1 | \
3228
# RUN: FileCheck --check-prefix=INVALID-EH-RELOCS %s
3329
# INVALID-EH-RELOCS: multiple relocation sections to .eh_frame are not supported

lld/test/ELF/merge-zero-size.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: ld.lld %p/Inputs/merge-shentsize-zero.elf -o %t2 2>&1 | \
2+
# RUN: FileCheck -allow-empty %s
3+
# CHECK-NOT: SHF_MERGE section size must be a multiple of sh_entsize
4+

0 commit comments

Comments
 (0)