[PATCH] D25233: [ELF] - Do not crash when unable to parse ELF object file.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 02:01:15 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283532: [ELF] - Do not crash when unable to parse ELF object file. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25233?vs=73752&id=73894#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25233
Files:
lld/trunk/ELF/Error.cpp
lld/trunk/ELF/Error.h
lld/trunk/ELF/InputFiles.cpp
lld/trunk/test/ELF/invalid/Inputs/too-short.elf
lld/trunk/test/ELF/invalid/too-short.s
Index: lld/trunk/ELF/Error.h
===================================================================
--- lld/trunk/ELF/Error.h
+++ lld/trunk/ELF/Error.h
@@ -45,6 +45,7 @@
}
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
+LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix);
template <class T> T check(ErrorOr<T> E) {
if (auto EC = E.getError())
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -57,7 +57,7 @@
std::error_code EC;
ELFFile<ELFT> F(MB.getBuffer(), EC);
if (EC)
- error(EC, "failed to read " + MB.getBufferIdentifier());
+ fatal(EC, "failed to read " + MB.getBufferIdentifier());
return F;
}
Index: lld/trunk/ELF/Error.cpp
===================================================================
--- lld/trunk/ELF/Error.cpp
+++ lld/trunk/ELF/Error.cpp
@@ -47,4 +47,8 @@
exit(1);
}
+void elf::fatal(std::error_code EC, const Twine &Prefix) {
+ fatal(Prefix + ": " + EC.message());
+}
+
} // namespace lld
Index: lld/trunk/test/ELF/invalid/too-short.s
===================================================================
--- lld/trunk/test/ELF/invalid/too-short.s
+++ lld/trunk/test/ELF/invalid/too-short.s
@@ -0,0 +1,5 @@
+# REQUIRES: x86
+
+## too-short.elf file is a truncated ELF.
+# RUN: not ld.lld %S/Inputs/too-short.elf -o %t 2>&1 | FileCheck %s
+# CHECK: failed to read
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25233.73894.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/7b89b67f/attachment.bin>
More information about the llvm-commits
mailing list