diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-05-28 19:45:51 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-05-28 19:45:51 +0000 |
commit | e21296626c06c0e788ecdb761f7e8a3574f1f36e (patch) | |
tree | f9138b5e38cbdd019c222bbcc0e33567bfbd1a29 /llvm/lib/Object/COFFObjectFile.cpp | |
parent | a6d93fd73b82579ddd1ec9965f726e29b33c4bab (diff) | |
download | bcm5719-llvm-e21296626c06c0e788ecdb761f7e8a3574f1f36e.tar.gz bcm5719-llvm-e21296626c06c0e788ecdb761f7e8a3574f1f36e.zip |
[Object] Return an error code instead of asserting
This makes it easier to report errors up the stack.
llvm-svn: 271140
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 489c69cc4bc..5f464969adb 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -950,10 +950,10 @@ uint64_t COFFObjectFile::getSectionSize(const coff_section *Sec) const { 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. |