[ELF] - Do not hang if broken object has option descriptor in .MIPS.options with size of zero.

Previously lld would hang in infinite loop in this case,
patch fixes the issue. Object was found during AFL run.

Differential revision: https://reviews.llvm.org/D25229

llvm-svn: 283208
This commit is contained in:
George Rimar 2016-10-04 10:23:07 +00:00
parent 06b7a87298
commit 422e47a9f5
3 changed files with 7 additions and 0 deletions

View File

@ -694,6 +694,8 @@ MipsOptionsInputSection<ELFT>::MipsOptionsInputSection(elf::ObjectFile<ELFT> *F,
error(getName(this) + ": unsupported non-zero ri_gp_value");
break;
}
if (!O->size)
fatal(getName(this) + ": zero option descriptor size");
D = D.slice(O->size);
}
}

View File

@ -0,0 +1,5 @@
## mips-invalid-options-descriptor.elf has option descriptor in
## .MIPS.options with size of zero.
# RUN: not ld.lld %p/Inputs/mips-invalid-options-descriptor.elf -o %t2 2>&1 | \
# RUN: FileCheck %s
# CHECK: zero option descriptor size