[Object, MachO] Don't crash on invalid MachO load commands.

Summary:
Currently all load commands are parsed in MachOObjectFile constructor.
If the next load command cannot be parsed, or if command size is too
small, properly report it through the error code and fail to construct
the object, instead of crashing the program.

Test Plan: regression test suite

Reviewers: rafael, filcab

Subscribers: llvm-commits
llvm-svn: 239080
This commit is contained in:
Alexey Samsonov
2015-06-04 19:57:46 +00:00
parent 31d9c47540
commit de5a94a6b4
4 changed files with 28 additions and 11 deletions

View File

@@ -44,6 +44,8 @@ std::string _object_error_category::message(int EV) const {
return "The end of the file was unexpectedly encountered";
case object_error::bitcode_section_not_found:
return "Bitcode section not found in object file";
case object_error::macho_small_load_command:
return "Mach-O load command with size < 8 bytes";
}
llvm_unreachable("An enumerator of object_error does not have a message "
"defined.");