Make LauncherGenerator to be able to shrink sections

This issue was found during investigation of T-IDE broken binary:
they've used an .ico file of smaller size than in IDEA, and that caused
the binary to become invalid.

GitOrigin-RevId: 9b14d581e27dd04e5e9f6c6d25665ae895d238d6
This commit is contained in:
Ivan Migalev
2020-07-01 07:49:41 +00:00
committed by intellij-monorepo-bot
parent 5f0630e50c
commit 3335afcf68
2 changed files with 1 additions and 5 deletions
Binary file not shown.
@@ -148,16 +148,12 @@ public class ExeReader extends Bin.Structure{
for (Bin sectionHeader : mySectionHeaders.getArray()) {
Value virtualAddressMember = ((ImageSectionHeader)sectionHeader).getValueMember("VirtualAddress");
long sectionVirtualAddress = virtualAddressMember.getValue();
// Section always starts from an address divisible by 0x1000
if (virtualAddress % 0x1000 != 0)
virtualAddress += 0x1000 - virtualAddress % 0x1000;
if (sectionVirtualAddress < virtualAddress) {
virtualAddressMember.setValue(virtualAddress);
}
virtualAddressMember.setValue(virtualAddress);
virtualAddress += ((ImageSectionHeader)sectionHeader).getValueMember("VirtualSize").getValue();
}