[lld] r252454 - [ELF2] - Fixed crash for case when section sh_entsize is set to zero for SHF_MERGE type of sections.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 9 00:41:01 PST 2015
Author: grimar
Date: Mon Nov 9 02:40:44 2015
New Revision: 252454
URL: http://llvm.org/viewvc/llvm-project?rev=252454&view=rev
Log:
[ELF2] - Fixed crash for case when section sh_entsize is set to zero for SHF_MERGE type of sections.
Differential revision: http://reviews.llvm.org/D14451
Added:
lld/trunk/test/elf2/Inputs/invalid-shentsize-zero.elf (with props)
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/test/elf2/invalid-elf.test
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=252454&r1=252453&r2=252454&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Mon Nov 9 02:40:44 2015
@@ -143,7 +143,7 @@ static bool shouldMerge(const typename E
if (Flags & SHF_WRITE)
error("Writable SHF_MERGE sections are not supported");
uintX_t EntSize = Sec.sh_entsize;
- if (Sec.sh_size % EntSize)
+ if (!EntSize || Sec.sh_size % EntSize)
error("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.
Added: lld/trunk/test/elf2/Inputs/invalid-shentsize-zero.elf
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/Inputs/invalid-shentsize-zero.elf?rev=252454&view=auto
==============================================================================
Binary file - no diff available.
Propchange: lld/trunk/test/elf2/Inputs/invalid-shentsize-zero.elf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: lld/trunk/test/elf2/invalid-elf.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/invalid-elf.test?rev=252454&r1=252453&r2=252454&view=diff
==============================================================================
--- lld/trunk/test/elf2/invalid-elf.test (original)
+++ lld/trunk/test/elf2/invalid-elf.test Mon Nov 9 02:40:44 2015
@@ -23,4 +23,8 @@
# RUN: not ld.lld2 %p/Inputs/invalid-shstrndx.so -o %t2 2>&1 | \
# RUN: FileCheck --check-prefix=INVALID-SECTION-INDEX %s
+# RUN: not ld.lld2 %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
+
.long foo
More information about the llvm-commits
mailing list