[Mono-bugs] [Bug 78182][Nor] New - peapi (used by ilasm)
GetNextSectionStart doesn't take in account data sizes %
section sizes = 0
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Apr 25 05:49:25 EDT 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by ck at carlo-kok.com.
http://bugzilla.ximian.com/show_bug.cgi?id=78182
--- shadow/78182 2006-04-25 05:49:25.000000000 -0400
+++ shadow/78182.tmp.32680 2006-04-25 05:49:25.000000000 -0400
@@ -0,0 +1,38 @@
+Bug#: 78182
+Product: Mono: Compilers
+Version: 1.0
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: IL assembler
+AssignedTo: jankit at novell.com
+ReportedBy: ck at carlo-kok.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: peapi (used by ilasm) GetNextSectionStart doesn't take in account data sizes % section sizes = 0
+
+PEAPI uses:
+private uint GetNextSectStart(uint rva, uint tide)
+{
+ if (tide < SectionAlignment) return rva + SectionAlignment;
+ return rva + ((tide / SectionAlignment) + 1) * SectionAlignment;
+}
+
+Problem is that if tide % SectionAlignment = 0 (for example when both are
+2000) it shouldn't add an extra 2000. Mono doesn't have a problem with
+this, but Windows does, it will refuse to load the executable all together.
+A simple fix for this is:
+
+private uint GetNextSectStart(uint rva, uint tide)
+{
+ uint c = tide / FileImage.SectionAlignment;
+ if (tide % FileImage.SectionAlignment != 0) c++;
+ return rva + (c * FileImage.SectionAlignment);
+}
+
+This way, it won't add the extra 2000 unless it's really needed.
More information about the mono-bugs
mailing list