+ 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 -
This commit is contained in:
nickysn 2018-06-21 15:51:58 +00:00
parent ab47c8b899
commit f4e26f382f
2 changed files with 28 additions and 1 deletions

View File

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

View File

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