[PATCH] D10939: Object/COFF: Fix getSectionSize
David Majnemer
david.majnemer at gmail.com
Fri Jul 3 20:12:02 PDT 2015
LGTM with review comments addressed.
================
Comment at: lib/Object/COFFObjectFile.cpp:920
@@ -919,5 +919,3 @@
//
- // 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
----------------
I would add a comment saying that `VirtualSize` **should** be zero for object files but isn't due to buggy COFF writers.
================
Comment at: lib/Object/COFFObjectFile.cpp:925
@@ -926,8 +924,3 @@
// 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);
----------------
You could reuse the existing logic by making this `if (getDOSHeader())`.
http://reviews.llvm.org/D10939
More information about the llvm-commits
mailing list