[ELF] - Do not crash when unable to parse ELF object file.
authorGeorge Rimar <grimar@accesssoftek.com>
Fri, 7 Oct 2016 08:51:57 +0000 (08:51 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Fri, 7 Oct 2016 08:51:57 +0000 (08:51 +0000)
commitb7aec331255e7be93652dfad94e817fd8b7be0b8
tree970bfe15c79ce9a95934faa0e36e61c5797bf9c2
parentd9edde4ae2cd3e5350c3a981f6715de9f2457196
[ELF] - Do not crash when unable to parse ELF object file.

createELFObj() may call error(...), for example when file is too short.
In that case header is not set and following line lead to crash:

EMachine = ELFObj.getHeader()->e_machine;

Patch fixes the issue.

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

llvm-svn: 283532
lld/ELF/Error.cpp
lld/ELF/Error.h
lld/ELF/InputFiles.cpp
lld/test/ELF/invalid/Inputs/too-short.elf [new file with mode: 0644]
lld/test/ELF/invalid/too-short.s [new file with mode: 0644]