This is an archive of the discontinued LLVM Phabricator instance.

Object/COFF: Fix getSectionSize
Needs ReviewPublic

Authored by ruiu on Jul 3 2015, 7:47 PM.

Details

Reviewers
majnemer
Summary

Some tools such as yasm set a bogus value to object file's
VirtualSize field, so we cannot trust this field. This patch
determines if it's an object or an executable by checking
existence of PE header.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 29041.Jul 3 2015, 7:47 PM
ruiu retitled this revision from to Object/COFF: Fix getSectionSize.
ruiu updated this object.
ruiu added a reviewer: majnemer.
ruiu added a subscriber: llvm-commits.
majnemer edited edge metadata.Jul 3 2015, 8:12 PM

LGTM with review comments addressed.

lib/Object/COFFObjectFile.cpp
920

I would add a comment saying that VirtualSize should be zero for object files but isn't due to buggy COFF writers.

925

You could reuse the existing logic by making this if (getDOSHeader()).