rainers / cv2pdb

converter of DMD CodeView/DWARF debug information to PDB files
Artistic License 2.0
472 stars 109 forks source link

OptionalHeader.SizeOfInitializedData remains unchanged after new section is added. #28

Open AlexWhiter opened 6 years ago

AlexWhiter commented 6 years ago

Since the debug section is marked as IMAGE_SCN_CNT_INITIALIZED_DATA, OptionalHeader.SizeOfInitializedData should be adjusted accordingly when this section is added. If a debug section was already present in the file, its flags should probably be checked to make sure SizeOfInitializedData is set to a correct value.

I'm not sure if this is a real problem. The EXEs and DLLs with unadjusted SizeOfInitializedData work just fine. It's just a matter of consistency.

rainers commented 6 years ago

Seems reasonable, but optlink (the DigitalMars linker that generates the usual executables processed with cv2pdb) doesn't write anything sensible to SizeOfInitializedData to begin with.

Checking some random Microsoft files, the sum of the section values also doesn't add up to SizeOfInitializedData so it really doesn't seem to be very important.

A patch should recalculate it from scratch.

AlexWhiter commented 6 years ago

This seems to depend on Windows version. The files I've checked in WIndoows XP, contained a correct value of SizeOfInitializedData. And, for example, explorer.exe in Win10 build 16299 has wrong physical size in .data section (0x1000 instead of 0x3e00). Corrected physical sizes of the initialized sections sum up to the same value as specified in SizeOfInitializedData.