* TOmfRelocation modified to build the omf FIXUP subrecord later, during

writeData, when the ObjSection indexes are available; now we fill the proper
  section/segment indexes, instead of hardcoded values.

git-svn-id: trunk@30489 -
This commit is contained in:
nickysn 2015-04-07 20:40:40 +00:00
parent 9e701454c6
commit 35e008e44b

View File

@ -46,10 +46,12 @@ interface
TOmfRelocation = class(TObjRelocation) TOmfRelocation = class(TObjRelocation)
private private
FOmfFixup: TOmfSubRecord_FIXUP; FOmfFixup: TOmfSubRecord_FIXUP;
function GetGroupIndex(const groupname: string): Integer;
public public
constructor CreateSymbol(ADataOffset:aword;s:TObjSymbol;Atyp:TObjRelocationType);
destructor Destroy; override; destructor Destroy; override;
procedure BuildOmfFixup;
property OmfFixup: TOmfSubRecord_FIXUP read FOmfFixup; property OmfFixup: TOmfSubRecord_FIXUP read FOmfFixup;
end; end;
@ -129,20 +131,12 @@ implementation
TOmfRelocation TOmfRelocation
****************************************************************************} ****************************************************************************}
constructor TOmfRelocation.CreateSymbol(ADataOffset: aword; s: TObjSymbol; Atyp: TObjRelocationType); function TOmfRelocation.GetGroupIndex(const groupname: string): Integer;
begin begin
inherited CreateSymbol(ADataOffset,s,Atyp); if groupname='dgroup' then
FOmfFixup:=TOmfSubRecord_FIXUP.Create; Result:=1
{ dummy data, TODO: fix } else
FOmfFixup.LocationOffset:=ADataOffset; internalerror(2014040703);
FOmfFixup.LocationType:=fltOffset;
FOmfFixup.FrameDeterminedByThread:=False;
FOmfFixup.TargetDeterminedByThread:=False;
FOmfFixup.Mode:=fmSegmentRelative;
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
FOmfFixup.TargetDatum:=3;
FOmfFixup.FrameMethod:=ffmGroupIndex;
FOmfFixup.FrameDatum:=1;
end; end;
destructor TOmfRelocation.Destroy; destructor TOmfRelocation.Destroy;
@ -151,6 +145,31 @@ implementation
inherited Destroy; inherited Destroy;
end; end;
procedure TOmfRelocation.BuildOmfFixup;
begin
FreeAndNil(FOmfFixup);
FOmfFixup:=TOmfSubRecord_FIXUP.Create;
if ObjSection<>nil then
begin
FOmfFixup.LocationOffset:=DataOffset;
FOmfFixup.LocationType:=fltOffset;
FOmfFixup.FrameDeterminedByThread:=False;
FOmfFixup.TargetDeterminedByThread:=False;
FOmfFixup.Mode:=fmSegmentRelative;
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
FOmfFixup.TargetDatum:=ObjSection.Index;
if TOmfObjSection(ObjSection).PrimaryGroup<>'' then
begin
FOmfFixup.FrameMethod:=ffmGroupIndex;
FOmfFixup.FrameDatum:=GetGroupIndex(TOmfObjSection(ObjSection).PrimaryGroup);
end
else
FOmfFixup.FrameMethod:=ffmTarget;
end
else
internalerror(2015040702);
end;
{**************************************************************************** {****************************************************************************
TOmfObjSection TOmfObjSection
****************************************************************************} ****************************************************************************}
@ -315,7 +334,7 @@ implementation
{ real address of the symbol } { real address of the symbol }
symaddr:=p.address; symaddr:=p.address;
objreloc:=TOmfRelocation.CreateSymbol(CurrObjSec.Size,p,Reloctype); objreloc:=TOmfRelocation.CreateSection(CurrObjSec.Size,p.objsection,Reloctype);
CurrObjSec.ObjRelocations.Add(objreloc); CurrObjSec.ObjRelocations.Add(objreloc);
inc(data,symaddr); inc(data,symaddr);
end; end;
@ -430,7 +449,7 @@ implementation
RawRecord.WriteTo(FWriter); RawRecord.WriteTo(FWriter);
{ write FIXUPP record } { write FIXUPP record }
while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and
(TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd+1]).OmfFixup.LocationOffset<(ChunkStart+ChunkLen)) do (TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd+1]).DataOffset<(ChunkStart+ChunkLen)) do
inc(ChunkFixupEnd); inc(ChunkFixupEnd);
if ChunkFixupEnd>=ChunkFixupStart then if ChunkFixupEnd>=ChunkFixupStart then
begin begin
@ -438,6 +457,7 @@ implementation
NextOfs:=0; NextOfs:=0;
for I:=ChunkFixupStart to ChunkFixupEnd do for I:=ChunkFixupStart to ChunkFixupEnd do
begin begin
TOmfRelocation(sec.ObjRelocations[I]).BuildOmfFixup;
TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.DataRecordStartOffset:=ChunkStart; TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.DataRecordStartOffset:=ChunkStart;
NextOfs:=TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.WriteAt(RawRecord,NextOfs); NextOfs:=TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.WriteAt(RawRecord,NextOfs);
end; end;