[llvm] r241387 - Object/COFF: Do not rely on VirtualSize being 0 in object files.
Rui Ueyama
ruiu at google.com
Fri Jul 3 20:25:51 PDT 2015
Author: ruiu
Date: Fri Jul 3 22:25:51 2015
New Revision: 241387
URL: http://llvm.org/viewvc/llvm-project?rev=241387&view=rev
Log:
Object/COFF: Do not rely on VirtualSize being 0 in object files.
Modified:
llvm/trunk/lib/Object/COFFObjectFile.cpp
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=241387&r1=241386&r2=241387&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Fri Jul 3 22:25:51 2015
@@ -918,19 +918,15 @@ uint64_t COFFObjectFile::getSectionSize(
// 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
More information about the llvm-commits
mailing list