diff options
author | Rui Ueyama <ruiu@google.com> | 2015-07-04 03:25:51 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-07-04 03:25:51 +0000 |
commit | d5297ee72449d9fadb94a796667b0aa56c4531ce (patch) | |
tree | 0bcb8835357efccd5251b8ef96832814f373164e /llvm/lib/Object/COFFObjectFile.cpp | |
parent | cffbe7cb554e2cfffa3759e54a0d87c20dd7636e (diff) | |
download | llvm-d5297ee72449d9fadb94a796667b0aa56c4531ce.zip llvm-d5297ee72449d9fadb94a796667b0aa56c4531ce.tar.gz llvm-d5297ee72449d9fadb94a796667b0aa56c4531ce.tar.bz2 |
Object/COFF: Do not rely on VirtualSize being 0 in object files.
llvm-svn: 241387
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 9c9a6df..19b53d8 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -918,19 +918,15 @@ uint64_t COFFObjectFile::getSectionSize(const coff_section *Sec) const { // whether or not we have an executable image. // // For object files, SizeOfRawData contains the size of section's data; - // VirtualSize is always zero. + // VirtualSize should be zero but isn't due to buggy COFF writers. // // For executables, SizeOfRawData *must* be a multiple of FileAlignment; the // actual section size is in VirtualSize. It is possible for VirtualSize to // be greater than SizeOfRawData; the contents past that point should be // considered to be zero. - uint32_t SectionSize; - if (Sec->VirtualSize) - SectionSize = std::min(Sec->VirtualSize, Sec->SizeOfRawData); - else - SectionSize = Sec->SizeOfRawData; - - return SectionSize; + if (getDOSHeader()) + return std::min(Sec->VirtualSize, Sec->SizeOfRawData); + return Sec->SizeOfRawData; } std::error_code |