diff options
author | Shoaib Meenai <smeenai@fb.com> | 2017-05-14 18:34:56 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2017-05-14 18:34:56 +0000 |
commit | ee97c5f0125e8f07ee53934bf607c5d518959cac (patch) | |
tree | 01dd3965aa76889366a401f7856c004932b59079 /llvm/lib/Object/COFFObjectFile.cpp | |
parent | 5bef9c627e44077e4ec5024be062faecc4eab3e5 (diff) | |
download | bcm5719-llvm-ee97c5f0125e8f07ee53934bf607c5d518959cac.tar.gz bcm5719-llvm-ee97c5f0125e8f07ee53934bf607c5d518959cac.zip |
[COFF] Gracefully handle empty .drectve sections
Running `llvm-readobj -coff-directives msvcrt.lib` resulted in this error:
Invalid data was encountered while parsing the file
This happened because some of the object files in the archive have empty
`.drectve` sections. These empty sections result in a `parse_failed` error being
returned from `COFFObjectFile::getSectionContents()`, which in turn caused
`llvm-readobj` to stop. With this change, `getSectionContents` now returns
success, and like before the resulting array is empty.
Patch by Dave Lee.
Differential Revision: https://reviews.llvm.org/D32652
llvm-svn: 303014
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index b7e4479bcad..28531feccfe 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -1062,7 +1062,7 @@ COFFObjectFile::getSectionContents(const coff_section *Sec, // 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; + return std::error_code(); // 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. |