Răsfoiți Sursa

+ added an 'index' field to TObjSectionGroup, specifying the index of the group
in the object file (similar to TObjSection.index, but for groups, instead of
sections). Set the new index field, when writing .obj files with the internal
omf object writer.

git-svn-id: trunk@39269 -

nickysn 7 ani în urmă
părinte
comite
f4e26f382f
2 a modificat fișierele cu 28 adăugiri și 1 ștergeri
  1. 1 0
      compiler/ogbase.pas
  2. 27 1
      compiler/ogomf.pas

+ 1 - 0
compiler/ogbase.pas

@@ -326,6 +326,7 @@ interface
 
 
      TObjSectionGroup = class(TFPHashObject)
      TObjSectionGroup = class(TFPHashObject)
      public
      public
+       index: longword;  { index of group in group headers }
        members: array of TObjSection;
        members: array of TObjSection;
        iscomdat: boolean;
        iscomdat: boolean;
      end;
      end;

+ 27 - 1
compiler/ogomf.pas

@@ -123,12 +123,14 @@ interface
         procedure AddSegment(const name,segclass,ovlname: string;
         procedure AddSegment(const name,segclass,ovlname: string;
           Alignment: TOmfSegmentAlignment; Combination: TOmfSegmentCombination;
           Alignment: TOmfSegmentAlignment; Combination: TOmfSegmentCombination;
           Use: TOmfSegmentUse; Size: TObjSectionOfs);
           Use: TOmfSegmentUse; Size: TObjSectionOfs);
+        procedure AddGroup(const groupname: string);
         procedure AddSegmentToGroup(const groupname: string; segindex: Integer);
         procedure AddSegmentToGroup(const groupname: string; segindex: Integer);
         procedure WriteSections(Data:TObjData);
         procedure WriteSections(Data:TObjData);
         procedure WriteSectionContentAndFixups(sec: TObjSection);
         procedure WriteSectionContentAndFixups(sec: TObjSection);
         procedure WriteLinNumRecords(sec: TOmfObjSection);
         procedure WriteLinNumRecords(sec: TOmfObjSection);
 
 
         procedure section_count_sections(p:TObject;arg:pointer);
         procedure section_count_sections(p:TObject;arg:pointer);
+        procedure group_count_groups(p:TObject;arg:pointer);
         procedure WritePUBDEFs(Data: TObjData);
         procedure WritePUBDEFs(Data: TObjData);
         procedure WriteEXTDEFs(Data: TObjData);
         procedure WriteEXTDEFs(Data: TObjData);
 
 
@@ -755,6 +757,15 @@ implementation
         s.SegmentLength:=Size;
         s.SegmentLength:=Size;
       end;
       end;
 
 
+    procedure TOmfObjOutput.AddGroup(const groupname: string);
+      var
+        g: TOmfRecord_GRPDEF;
+      begin
+        g:=TOmfRecord_GRPDEF.Create;
+        Groups.Add(groupname,g);
+        g.GroupNameIndex:=LNames.Add(groupname);
+      end;
+
     procedure TOmfObjOutput.AddSegmentToGroup(const groupname: string; segindex: Integer);
     procedure TOmfObjOutput.AddSegmentToGroup(const groupname: string; segindex: Integer);
       var
       var
         g: TOmfRecord_GRPDEF;
         g: TOmfRecord_GRPDEF;
@@ -908,6 +919,12 @@ implementation
         inc(pinteger(arg)^);
         inc(pinteger(arg)^);
       end;
       end;
 
 
+    procedure TOmfObjOutput.group_count_groups(p: TObject; arg: pointer);
+      begin
+        TObjSectionGroup(p).index:=pinteger(arg)^;
+        inc(pinteger(arg)^);
+      end;
+
     procedure TOmfObjOutput.WritePUBDEFs(Data: TObjData);
     procedure TOmfObjOutput.WritePUBDEFs(Data: TObjData);
       var
       var
         PubNamesForSection: array of TFPHashObjectList;
         PubNamesForSection: array of TFPHashObjectList;
@@ -1016,15 +1033,21 @@ implementation
         I: Integer;
         I: Integer;
         SegDef: TOmfRecord_SEGDEF;
         SegDef: TOmfRecord_SEGDEF;
         GrpDef: TOmfRecord_GRPDEF;
         GrpDef: TOmfRecord_GRPDEF;
-        nsections: Integer;
+        nsections,ngroups: Integer;
         objsym: TObjSymbol;
         objsym: TObjSymbol;
       begin
       begin
         { calc amount of sections we have and set their index, starting with 1 }
         { calc amount of sections we have and set their index, starting with 1 }
         nsections:=1;
         nsections:=1;
         data.ObjSectionList.ForEachCall(@section_count_sections,@nsections);
         data.ObjSectionList.ForEachCall(@section_count_sections,@nsections);
+        { calc amount of groups we have and set their index, starting with 1 }
+        ngroups:=1;
+        data.GroupsList.ForEachCall(@group_count_groups,@ngroups);
         { maximum amount of sections supported in the omf format is $7fff }
         { maximum amount of sections supported in the omf format is $7fff }
         if (nsections-1)>$7fff then
         if (nsections-1)>$7fff then
           internalerror(2015040701);
           internalerror(2015040701);
+        { maximum amount of groups supported in the omf format is $7fff }
+        if (ngroups-1)>$7fff then
+          internalerror(2018062101);
 
 
         { write header record }
         { write header record }
         RawRecord:=TOmfRawRecord.Create;
         RawRecord:=TOmfRawRecord.Create;
@@ -1065,6 +1088,9 @@ implementation
         FGroups.Clear;
         FGroups.Clear;
         FGroups.Add('',nil);
         FGroups.Add('',nil);
 
 
+        for i:=0 to Data.GroupsList.Count-1 do
+          with TObjSectionGroup(Data.GroupsList[I]) do
+            AddGroup(Name);
         for i:=0 to Data.ObjSectionList.Count-1 do
         for i:=0 to Data.ObjSectionList.Count-1 do
           with TOmfObjSection(Data.ObjSectionList[I]) do
           with TOmfObjSection(Data.ObjSectionList[I]) do
             begin
             begin