Index: lib/Object/COFFObjectFile.cpp =================================================================== --- lib/Object/COFFObjectFile.cpp +++ lib/Object/COFFObjectFile.cpp @@ -917,20 +917,14 @@ // SizeOfRawData and VirtualSize change what they represent depending on // whether or not we have an executable image. // - // For object files, SizeOfRawData contains the size of section's data; - // VirtualSize is always zero. - // + // For object files, SizeOfRawData contains the size of section's data. // 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 (PE32Header || PE32PlusHeader) + return std::min(Sec->VirtualSize, Sec->SizeOfRawData); + return Sec->SizeOfRawData; } std::error_code