[PATCH] [Request, 9 lines] D25082: [ELF] - Do not crash on invalid section alignment.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 02:15:03 PDT 2016
grimar created this revision.
grimar added reviewers: rafael, ruiu, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Case was revealed by id_000010,sig_08,src_000000,op_havoc,rep_4 from PR30540.
Out implementation uses uint32 for storing section alignment value,
what seems reasonable, though if value exceeds 32 bits bounds we have
truncation and final value of 0.
afl-min was applied to input.
https://reviews.llvm.org/D25082
Files:
ELF/InputSection.cpp
test/ELF/invalid/Inputs/section-alignment.elf
test/ELF/invalid/section-alignment.s
Index: test/ELF/invalid/section-alignment.s
===================================================================
--- test/ELF/invalid/section-alignment.s
+++ test/ELF/invalid/section-alignment.s
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+
+## In current lld implementation, we do not accept sh_addralign
+## larger than UINT32_MAX.
+# RUN: not ld.lld %S/Inputs/section-alignment.elf \
+# RUN: -o %t 2>&1 | FileCheck %s
+# CHECK: section sh_addralign is too large
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -45,6 +45,8 @@
Header(Hdr), File(File), Repl(this) {
// The ELF spec states that a value of 0 means the section has
// no alignment constraits.
+ if (Header->sh_addralign > UINT32_MAX)
+ fatal(getFilename(File) + ": section sh_addralign is too large");
Alignment = std::max<uintX_t>(Header->sh_addralign, 1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25082.73012.patch
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/874a87e7/attachment.bin>
More information about the llvm-commits
mailing list