mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 14:09:59 +02:00
* 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:
parent
9e701454c6
commit
35e008e44b
@ -46,10 +46,12 @@ interface
|
||||
TOmfRelocation = class(TObjRelocation)
|
||||
private
|
||||
FOmfFixup: TOmfSubRecord_FIXUP;
|
||||
function GetGroupIndex(const groupname: string): Integer;
|
||||
public
|
||||
constructor CreateSymbol(ADataOffset:aword;s:TObjSymbol;Atyp:TObjRelocationType);
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure BuildOmfFixup;
|
||||
|
||||
property OmfFixup: TOmfSubRecord_FIXUP read FOmfFixup;
|
||||
end;
|
||||
|
||||
@ -129,20 +131,12 @@ implementation
|
||||
TOmfRelocation
|
||||
****************************************************************************}
|
||||
|
||||
constructor TOmfRelocation.CreateSymbol(ADataOffset: aword; s: TObjSymbol; Atyp: TObjRelocationType);
|
||||
function TOmfRelocation.GetGroupIndex(const groupname: string): Integer;
|
||||
begin
|
||||
inherited CreateSymbol(ADataOffset,s,Atyp);
|
||||
FOmfFixup:=TOmfSubRecord_FIXUP.Create;
|
||||
{ dummy data, TODO: fix }
|
||||
FOmfFixup.LocationOffset:=ADataOffset;
|
||||
FOmfFixup.LocationType:=fltOffset;
|
||||
FOmfFixup.FrameDeterminedByThread:=False;
|
||||
FOmfFixup.TargetDeterminedByThread:=False;
|
||||
FOmfFixup.Mode:=fmSegmentRelative;
|
||||
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=3;
|
||||
FOmfFixup.FrameMethod:=ffmGroupIndex;
|
||||
FOmfFixup.FrameDatum:=1;
|
||||
if groupname='dgroup' then
|
||||
Result:=1
|
||||
else
|
||||
internalerror(2014040703);
|
||||
end;
|
||||
|
||||
destructor TOmfRelocation.Destroy;
|
||||
@ -151,6 +145,31 @@ implementation
|
||||
inherited Destroy;
|
||||
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
|
||||
****************************************************************************}
|
||||
@ -315,7 +334,7 @@ implementation
|
||||
{ real address of the symbol }
|
||||
symaddr:=p.address;
|
||||
|
||||
objreloc:=TOmfRelocation.CreateSymbol(CurrObjSec.Size,p,Reloctype);
|
||||
objreloc:=TOmfRelocation.CreateSection(CurrObjSec.Size,p.objsection,Reloctype);
|
||||
CurrObjSec.ObjRelocations.Add(objreloc);
|
||||
inc(data,symaddr);
|
||||
end;
|
||||
@ -430,7 +449,7 @@ implementation
|
||||
RawRecord.WriteTo(FWriter);
|
||||
{ write FIXUPP record }
|
||||
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);
|
||||
if ChunkFixupEnd>=ChunkFixupStart then
|
||||
begin
|
||||
@ -438,6 +457,7 @@ implementation
|
||||
NextOfs:=0;
|
||||
for I:=ChunkFixupStart to ChunkFixupEnd do
|
||||
begin
|
||||
TOmfRelocation(sec.ObjRelocations[I]).BuildOmfFixup;
|
||||
TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.DataRecordStartOffset:=ChunkStart;
|
||||
NextOfs:=TOmfRelocation(sec.ObjRelocations[I]).OmfFixup.WriteAt(RawRecord,NextOfs);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user