Object, COFF: Cap the section contents to min(VirtualSize, SizeOfRawData)
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Oct 2014 07:49:28 +0000 (07:49 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 9 Oct 2014 07:49:28 +0000 (07:49 +0000)
commit5b1b9844e749a994609f4da3b40f20a338674a53
tree684d4e4ebd8bc1260f958e42f0bf3efd4e628262
parentd9b7ba1506ed6913cec77d4931f62efaf86204fe
Object, COFF: Cap the section contents to min(VirtualSize, SizeOfRawData)

It is not useful to return the data beyond VirtualSize it's less than
SizeOfRawData.

An implementation detail of COFF requires the section size to be rounded
up to a multiple of FileAlignment; this means that SizeOfRawData is not
representative of how large the section is.  Instead, we should cap it
to VirtualSize when this occurs as it represents the true size of the
section.

Note that this is only relevant in executable files because this
rounding doesn't occur in object files (and VirtualSize is always zero).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219388 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Object/COFFObjectFile.cpp