Browse Source

+ count omf sections and set their index starting with 1

git-svn-id: trunk@30477 -
nickysn 10 years ago
parent
commit
1d236e8386
1 changed files with 16 additions and 0 deletions
  1. 16 0
      compiler/ogomf.pas

+ 16 - 0
compiler/ogomf.pas

@@ -98,6 +98,8 @@ interface
         procedure WriteSections(Data:TObjData);
         procedure WriteSectionContentAndFixups(sec: TObjSection);
 
+        procedure section_count_sections(p:TObject;arg:pointer);
+
         property LNames: TOmfOrderedNameCollection read FLNames;
         property Segments: TFPHashObjectList read FSegments;
         property Groups: TFPHashObjectList read FGroups;
@@ -440,6 +442,12 @@ implementation
           end;
       end;
 
+    procedure TOmfObjOutput.section_count_sections(p: TObject; arg: pointer);
+      begin
+        TOmfObjSection(p).index:=pinteger(arg)^;
+        inc(pinteger(arg)^);
+      end;
+
     function TOmfObjOutput.writeData(Data:TObjData):boolean;
       var
         RawRecord: TOmfRawRecord;
@@ -451,7 +459,15 @@ implementation
         I: Integer;
         SegDef: TOmfRecord_SEGDEF;
         GrpDef: TOmfRecord_GRPDEF;
+        nsections: Integer;
       begin
+        { calc amount of sections we have and set their index, starting with 1 }
+        nsections:=1;
+        data.ObjSectionList.ForEachCall(@section_count_sections,@nsections);
+        { maximum amount of sections supported in the omf format is $7fff }
+        if (nsections-1)>$7fff then
+          internalerror(2015040701);
+
         { write header record }
         RawRecord:=TOmfRawRecord.Create;
         Header:=TOmfRecord_THEADR.Create;