Răsfoiți Sursa

+ added the missing NewExe segment attributes as properties to the
TNewExeSection class and create the NewExe segment table into the .exe file.
Not all of the properties are initialized yet, though.

git-svn-id: trunk@42587 -

nickysn 6 ani în urmă
părinte
comite
7132973847
1 a modificat fișierele cu 31 adăugiri și 0 ștergeri
  1. 31 0
      compiler/ogomf.pas

+ 31 - 0
compiler/ogomf.pas

@@ -497,13 +497,20 @@ interface
         FEarlySize: QWord;
         FEarlySize: QWord;
         FExeMetaSec: TNewExeMetaSection;
         FExeMetaSec: TNewExeMetaSection;
         FMemBasePos: Word;
         FMemBasePos: Word;
+        FDataPosSectors: Word;
+        FMinAllocSize: QWord;
+        FNewExeSegmentFlags: TNewExeSegmentFlags;
       public
       public
+        procedure WriteHeaderTo(aWriter: TObjectWriter);
         function MemPosStr(AImageBase: qword): string;override;
         function MemPosStr(AImageBase: qword): string;override;
         procedure AddObjSection(objsec:TObjSection;ignoreprops:boolean=false);override;
         procedure AddObjSection(objsec:TObjSection;ignoreprops:boolean=false);override;
         function CanAddObjSection(objsec:TObjSection;ExeSectionLimit:QWord):boolean;
         function CanAddObjSection(objsec:TObjSection;ExeSectionLimit:QWord):boolean;
         property EarlySize: QWord read FEarlySize write FEarlySize;
         property EarlySize: QWord read FEarlySize write FEarlySize;
         property ExeMetaSec: TNewExeMetaSection read FExeMetaSec write FExeMetaSec;
         property ExeMetaSec: TNewExeMetaSection read FExeMetaSec write FExeMetaSec;
         property MemBasePos: Word read FMemBasePos write FMemBasePos;
         property MemBasePos: Word read FMemBasePos write FMemBasePos;
+        property DataPosSectors: Word read FDataPosSectors write FDataPosSectors;
+        property MinAllocSize: QWord read FMinAllocSize write FMinAllocSize;
+        property NewExeSegmentFlags: TNewExeSegmentFlags read FNewExeSegmentFlags write FNewExeSegmentFlags;
       end;
       end;
 
 
       { TNewExeOutput }
       { TNewExeOutput }
@@ -3591,6 +3598,22 @@ cleanup:
                               TNewExeSection
                               TNewExeSection
 ****************************************************************************}
 ****************************************************************************}
 
 
+    procedure TNewExeSection.WriteHeaderTo(aWriter: TObjectWriter);
+      var
+        SegmentHeaderBytes: array [0..7] of Byte;
+      begin
+        SegmentHeaderBytes[0]:=Byte(DataPosSectors);
+        SegmentHeaderBytes[1]:=Byte(DataPosSectors shr 8);
+        SegmentHeaderBytes[2]:=Byte(Size);
+        SegmentHeaderBytes[3]:=Byte(Size shr 8);
+        SegmentHeaderBytes[4]:=Byte(Word(NewExeSegmentFlags));
+        SegmentHeaderBytes[5]:=Byte(Word(NewExeSegmentFlags) shr 8);
+        SegmentHeaderBytes[6]:=Byte(MinAllocSize);
+        SegmentHeaderBytes[7]:=Byte(MinAllocSize shr 8);
+
+        aWriter.write(SegmentHeaderBytes[0],8);
+      end;
+
     function TNewExeSection.MemPosStr(AImageBase: qword): string;
     function TNewExeSection.MemPosStr(AImageBase: qword): string;
       begin
       begin
         Result:=HexStr(MemBasePos,4)+':'+HexStr(MemPos,4);
         Result:=HexStr(MemBasePos,4)+':'+HexStr(MemPos,4);
@@ -3669,6 +3692,8 @@ cleanup:
       end;
       end;
 
 
     function TNewExeOutput.WriteNewExe: boolean;
     function TNewExeOutput.WriteNewExe: boolean;
+      var
+        i: Integer;
       begin
       begin
         Header.InitialIP:=EntrySym.address;
         Header.InitialIP:=EntrySym.address;
         Header.InitialCS:=TNewExeSection(EntrySym.objsection.ExeSection).MemBasePos;
         Header.InitialCS:=TNewExeSection(EntrySym.objsection.ExeSection).MemBasePos;
@@ -3676,9 +3701,15 @@ cleanup:
         Header.InitialSS:=Header.AutoDataSegmentNumber;
         Header.InitialSS:=Header.AutoDataSegmentNumber;
 
 
         Header.SegmentTableStart:=NewExeHeaderSize;
         Header.SegmentTableStart:=NewExeHeaderSize;
+        Header.SegmentTableEntriesCount:=ExeSectionList.Count;
 
 
         Header.WriteTo(FWriter);
         Header.WriteTo(FWriter);
+
+        for i:=0 to ExeSectionList.Count-1 do
+          TNewExeSection(ExeSectionList[i]).WriteHeaderTo(FWriter);
+
         { todo: write the rest of the file as well }
         { todo: write the rest of the file as well }
+
         Result:=True;
         Result:=True;
       end;
       end;