]> granicus.if.org Git - llvm/commit
[COFF] Gracefully handle empty .drectve sections
authorShoaib Meenai <smeenai@fb.com>
Sun, 14 May 2017 18:34:56 +0000 (18:34 +0000)
committerShoaib Meenai <smeenai@fb.com>
Sun, 14 May 2017 18:34:56 +0000 (18:34 +0000)
commit61e19cf8a48519f3f96081b5ea0fa7cba942926d
tree1607711bb4428c89bafa94858ee9ecb89b07746c
parent40a0941bb95d216ae46e4a5946ab15df62585f7d
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303014 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Object/COFFObjectFile.cpp
test/Object/Inputs/COFF/empty-drectve.yaml [new file with mode: 0644]
test/Object/coff-empty-drectve.test [new file with mode: 0644]