Bläddra i källkod

+ write mz exe section data
+ fill MaxExtraParagraphs in the MZ header with $ffff by default, to prevent DOS
from loading the program at the highest possible address

git-svn-id: trunk@31386 -

nickysn 10 år sedan
förälder
incheckning
449506ffb7
1 ändrade filer med 18 tillägg och 0 borttagningar
  1. 18 0
      compiler/ogomf.pas

+ 18 - 0
compiler/ogomf.pas

@@ -2086,6 +2086,7 @@ implementation
 
     procedure TMZExeOutput.FillHeaderData;
       begin
+        Header.MaxExtraParagraphs:=$FFFF;
         FillLoadableImageSize;
         FillStartAddress;
         if assigned(exemap) then
@@ -2093,10 +2094,27 @@ implementation
       end;
 
     function TMZExeOutput.writeExe: boolean;
+      var
+        ExeSec: TMZExeSection;
+        i: Integer;
+        ObjSec: TOmfObjSection;
       begin
         Result:=False;
         FillHeaderData;
         Header.WriteTo(FWriter);
+
+        ExeSec:=MZFlatContentSection;
+        ExeSec.DataPos:=FWriter.Size;
+        for i:=0 to ExeSec.ObjSectionList.Count-1 do
+          begin
+            ObjSec:=TOmfObjSection(ExeSec.ObjSectionList[i]);
+            if ObjSec.MemPos<Header.LoadableImageSize then
+              begin
+                FWriter.WriteZeros(max(0,ObjSec.MemPos-FWriter.Size+ExeSec.DataPos));
+                if assigned(ObjSec.Data) then
+                  FWriter.writearray(ObjSec.Data);
+              end;
+          end;
         Result:=True;
       end;