[llvm] r271140 - [Object] Return an error code instead of asserting
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat May 28 12:45:52 PDT 2016
Author: majnemer
Date: Sat May 28 14:45:51 2016
New Revision: 271140
URL: http://llvm.org/viewvc/llvm-project?rev=271140&view=rev
Log:
[Object] Return an error code instead of asserting
This makes it easier to report errors up the stack.
Modified:
llvm/trunk/lib/Object/COFFObjectFile.cpp
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=271140&r1=271139&r2=271140&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Sat May 28 14:45:51 2016
@@ -950,10 +950,10 @@ uint64_t COFFObjectFile::getSectionSize(
std::error_code
COFFObjectFile::getSectionContents(const coff_section *Sec,
ArrayRef<uint8_t> &Res) const {
- // PointerToRawData and SizeOfRawData won't make sense for BSS sections,
- // don't do anything interesting for them.
- assert((Sec->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) == 0 &&
- "BSS sections don't have contents!");
+ // In COFF, a virtual section won't have any in-file
+ // content, so the file pointer to the content will be zero.
+ if (Sec->PointerToRawData == 0)
+ return object_error::parse_failed;
// The only thing that we need to verify is that the contents is contained
// within the file bounds. We don't need to make sure it doesn't cover other
// data, as there's nothing that says that is not allowed.
More information about the llvm-commits
mailing list