Add the first of what will be a long line of additional error checks for invalid Mach-O files.

This is where an LC_SEGMENT load command has a fileoff field that
extends past the end of the file.

Also fix llvm-nm and llvm-size to remove the errorToErrorCode() call so error messages are printed.
And needed to update a few test cases now that they do print the error messages just a
bit differently.

llvm-svn: 277845
This commit is contained in:
Kevin Enderby
2016-08-05 18:19:40 +00:00
parent 0f4f0c5d53
commit 600fb3f28e
7 changed files with 18 additions and 4 deletions

View File

@@ -521,7 +521,7 @@ static void printFileSectionSizes(StringRef file) {
// Attempt to open the binary.
Expected<OwningBinary<Binary>> BinaryOrErr = createBinary(file);
if (!BinaryOrErr) {
error(errorToErrorCode(BinaryOrErr.takeError()));
error(BinaryOrErr.takeError(), file);
return;
}
Binary &Bin = *BinaryOrErr.get().getBinary();