Browse Source

+ fill SizeInFile properly in the NewExe segment table

git-svn-id: trunk@42662 -
nickysn 6 years ago
parent
commit
5edc520468
1 changed files with 8 additions and 3 deletions
  1. 8 3
      compiler/ogomf.pas

+ 8 - 3
compiler/ogomf.pas

@@ -646,6 +646,7 @@ interface
         FMemBasePos: Word;
         FMemBasePos: Word;
         FDataPosSectors: Word;
         FDataPosSectors: Word;
         FNewExeSegmentFlags: TNewExeSegmentFlags;
         FNewExeSegmentFlags: TNewExeSegmentFlags;
+        FSizeInFile: QWord;
         function GetMinAllocSize: QWord;
         function GetMinAllocSize: QWord;
       public
       public
         procedure WriteHeaderTo(aWriter: TObjectWriter);
         procedure WriteHeaderTo(aWriter: TObjectWriter);
@@ -658,6 +659,7 @@ interface
         property MemBasePos: Word read FMemBasePos write FMemBasePos;
         property MemBasePos: Word read FMemBasePos write FMemBasePos;
         property DataPosSectors: Word read FDataPosSectors write FDataPosSectors;
         property DataPosSectors: Word read FDataPosSectors write FDataPosSectors;
         property MinAllocSize: QWord read GetMinAllocSize;
         property MinAllocSize: QWord read GetMinAllocSize;
+        property SizeInFile: QWord read FSizeInFile write FSizeInFile;
         property NewExeSegmentFlags: TNewExeSegmentFlags read FNewExeSegmentFlags write FNewExeSegmentFlags;
         property NewExeSegmentFlags: TNewExeSegmentFlags read FNewExeSegmentFlags write FNewExeSegmentFlags;
       end;
       end;
 
 
@@ -4167,8 +4169,8 @@ cleanup:
       begin
       begin
         SegmentHeaderBytes[0]:=Byte(DataPosSectors);
         SegmentHeaderBytes[0]:=Byte(DataPosSectors);
         SegmentHeaderBytes[1]:=Byte(DataPosSectors shr 8);
         SegmentHeaderBytes[1]:=Byte(DataPosSectors shr 8);
-        SegmentHeaderBytes[2]:=Byte(Size);
-        SegmentHeaderBytes[3]:=Byte(Size shr 8);
+        SegmentHeaderBytes[2]:=Byte(SizeInFile);
+        SegmentHeaderBytes[3]:=Byte(SizeInFile shr 8);
         SegmentHeaderBytes[4]:=Byte(Word(NewExeSegmentFlags));
         SegmentHeaderBytes[4]:=Byte(Word(NewExeSegmentFlags));
         SegmentHeaderBytes[5]:=Byte(Word(NewExeSegmentFlags) shr 8);
         SegmentHeaderBytes[5]:=Byte(Word(NewExeSegmentFlags) shr 8);
         SegmentHeaderBytes[6]:=Byte(MinAllocSize);
         SegmentHeaderBytes[6]:=Byte(MinAllocSize);
@@ -4187,11 +4189,12 @@ cleanup:
         s: TSymStr;
         s: TSymStr;
         Separator: SizeInt;
         Separator: SizeInt;
         SegName, SegClass: string;
         SegName, SegClass: string;
-        IsStack: Boolean;
+        IsStack, IsBss: Boolean;
       begin
       begin
         { allow mixing initialized and uninitialized data in the same section
         { allow mixing initialized and uninitialized data in the same section
           => set ignoreprops=true }
           => set ignoreprops=true }
         inherited AddObjSection(objsec,true);
         inherited AddObjSection(objsec,true);
+        IsBss:=not(oso_Data in objsec.SecOptions);
         s:=objsec.Name;
         s:=objsec.Name;
         { name format is 'SegName||ClassName' }
         { name format is 'SegName||ClassName' }
         Separator:=Pos('||',s);
         Separator:=Pos('||',s);
@@ -4216,6 +4219,8 @@ cleanup:
         if IsStack then
         if IsStack then
           StackSize:=StackSize+objsec.Size;
           StackSize:=StackSize+objsec.Size;
         EarlySize:=align_qword(EarlySize,SecAlign)+objsec.Size;
         EarlySize:=align_qword(EarlySize,SecAlign)+objsec.Size;
+        if (not IsBss) and (not IsStack) then
+          SizeInFile:=EarlySize;
       end;
       end;
 
 
     function TNewExeSection.CanAddObjSection(objsec: TObjSection; ExeSectionLimit: QWord): boolean;
     function TNewExeSection.CanAddObjSection(objsec: TObjSection; ExeSectionLimit: QWord): boolean;