Kaynağa Gözat

+ support segments (sections) with a primary group, other than 'DGROUP' in the
OMF internal object writer

git-svn-id: trunk@39245 -

nickysn 7 yıl önce
ebeveyn
işleme
5eb69edf9e
2 değiştirilmiş dosya ile 24 ekleme ve 50 silme
  1. 15 49
      compiler/ogomf.pas
  2. 9 1
      compiler/omfbase.pas

+ 15 - 49
compiler/ogomf.pas

@@ -123,8 +123,7 @@ interface
         procedure AddSegment(const name,segclass,ovlname: string;
           Alignment: TOmfSegmentAlignment; Combination: TOmfSegmentCombination;
           Use: TOmfSegmentUse; Size: TObjSectionOfs);
-        procedure AddGroup(const groupname: string; seglist: array of const);
-        procedure AddGroup(const groupname: string; seglist: TSegmentList);
+        procedure AddSegmentToGroup(const groupname: string; segindex: Integer);
         procedure WriteSections(Data:TObjData);
         procedure WriteSectionContentAndFixups(sec: TObjSection);
         procedure WriteLinNumRecords(sec: TOmfObjSection);
@@ -757,42 +756,18 @@ implementation
         s.SegmentLength:=Size;
       end;
 
-    procedure TOmfObjOutput.AddGroup(const groupname: string; seglist: array of const);
-      var
-        g: TOmfRecord_GRPDEF;
-        I: Integer;
-        SegListStr: TSegmentList;
-      begin
-        g:=TOmfRecord_GRPDEF.Create;
-        Groups.Add(groupname,g);
-        g.GroupNameIndex:=LNames.Add(groupname);
-        SetLength(SegListStr,Length(seglist));
-        for I:=0 to High(seglist) do
-          begin
-            case seglist[I].VType of
-              vtString:
-                SegListStr[I]:=Segments.FindIndexOf(seglist[I].VString^);
-              vtAnsiString:
-                SegListStr[I]:=Segments.FindIndexOf(AnsiString(seglist[I].VAnsiString));
-              vtWideString:
-                SegListStr[I]:=Segments.FindIndexOf(AnsiString(WideString(seglist[I].VWideString)));
-              vtUnicodeString:
-                SegListStr[I]:=Segments.FindIndexOf(AnsiString(UnicodeString(seglist[I].VUnicodeString)));
-              else
-                internalerror(2015040402);
-            end;
-          end;
-        g.SegmentList:=SegListStr;
-      end;
-
-    procedure TOmfObjOutput.AddGroup(const groupname: string; seglist: TSegmentList);
+    procedure TOmfObjOutput.AddSegmentToGroup(const groupname: string; segindex: Integer);
       var
         g: TOmfRecord_GRPDEF;
       begin
-        g:=TOmfRecord_GRPDEF.Create;
-        Groups.Add(groupname,g);
-        g.GroupNameIndex:=LNames.Add(groupname);
-        g.SegmentList:=Copy(seglist);
+        g:=TOmfRecord_GRPDEF(Groups.Find(groupname));
+        if g=nil then
+          begin
+            g:=TOmfRecord_GRPDEF.Create;
+            Groups.Add(groupname,g);
+            g.GroupNameIndex:=LNames.Add(groupname);
+          end;
+        g.AddSegmentIndex(segindex);
       end;
 
     procedure TOmfObjOutput.WriteSections(Data: TObjData);
@@ -1042,7 +1017,6 @@ implementation
         I: Integer;
         SegDef: TOmfRecord_SEGDEF;
         GrpDef: TOmfRecord_GRPDEF;
-        DGroupSegments: TSegmentList;
         nsections: Integer;
         objsym: TObjSymbol;
       begin
@@ -1094,19 +1068,11 @@ implementation
 
         for i:=0 to Data.ObjSectionList.Count-1 do
           with TOmfObjSection(Data.ObjSectionList[I]) do
-            AddSegment(Name,ClassName,OverlayName,OmfAlignment,Combination,Use,Size);
-
-
-        { create group "DGROUP" }
-        SetLength(DGroupSegments,0);
-        for i:=0 to Data.ObjSectionList.Count-1 do
-          with TOmfObjSection(Data.ObjSectionList[I]) do
-            if PrimaryGroup='DGROUP' then
-              begin
-                SetLength(DGroupSegments,Length(DGroupSegments)+1);
-                DGroupSegments[High(DGroupSegments)]:=index;
-              end;
-        AddGroup('DGROUP',DGroupSegments);
+            begin
+              AddSegment(Name,ClassName,OverlayName,OmfAlignment,Combination,Use,Size);
+              if PrimaryGroup<>'' then
+                AddSegmentToGroup(PrimaryGroup,index);
+            end;
 
         { write LNAMES record(s) }
         LNamesRec:=TOmfRecord_LNAMES.Create;

+ 9 - 1
compiler/omfbase.pas

@@ -383,6 +383,8 @@ interface
       procedure DecodeFrom(RawRecord: TOmfRawRecord);override;
       procedure EncodeTo(RawRecord: TOmfRawRecord);override;
 
+      procedure AddSegmentIndex(segidx: Integer);
+
       property GroupNameIndex: Integer read FGroupNameIndex write FGroupNameIndex;
       property SegmentList: TSegmentList read FSegmentList write FSegmentList;
     end;
@@ -1737,9 +1739,15 @@ implementation
       RawRecord.CalculateChecksumByte;
     end;
 
+  procedure TOmfRecord_GRPDEF.AddSegmentIndex(segidx: Integer);
+    begin
+      SetLength(FSegmentList,Length(FSegmentList)+1);
+      FSegmentList[High(FSegmentList)]:=segidx;
+    end;
+
   { TOmfPublicNameElement }
 
-    function TOmfPublicNameElement.GetLengthInFile(Is32Bit: Boolean): Integer;
+  function TOmfPublicNameElement.GetLengthInFile(Is32Bit: Boolean): Integer;
     begin
       Result:=1+Length(Name)+2+1;
       if Is32Bit then