mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-10 07:38:49 +02:00
+ implemented TIntelHexExeOutput.DoRelocationFixup
git-svn-id: trunk@45577 -
This commit is contained in:
parent
3023a9f0e2
commit
12dce172f9
@ -1259,7 +1259,56 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIntelHexExeOutput.DoRelocationFixup(objsec: TObjSection);
|
procedure TIntelHexExeOutput.DoRelocationFixup(objsec: TObjSection);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
objreloc: TRelRelocation;
|
||||||
|
target,w: Word;
|
||||||
|
b: Byte;
|
||||||
begin
|
begin
|
||||||
|
for i:=0 to objsec.ObjRelocations.Count-1 do
|
||||||
|
begin
|
||||||
|
objreloc:=TRelRelocation(objsec.ObjRelocations[i]);
|
||||||
|
if assigned(objreloc.symbol) then
|
||||||
|
target:=objreloc.symbol.address+ImageBase
|
||||||
|
else if assigned(objreloc.objsection) then
|
||||||
|
target:=objreloc.objsection.MemPos+ImageBase
|
||||||
|
else
|
||||||
|
internalerror(2020060302);
|
||||||
|
case objreloc.typ of
|
||||||
|
RELOC_ABSOLUTE:
|
||||||
|
begin
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.read(w,2);
|
||||||
|
w:=LEtoN(w);
|
||||||
|
Inc(w,target);
|
||||||
|
w:=LEtoN(w);
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.write(w,2);
|
||||||
|
end;
|
||||||
|
RELOC_ABSOLUTE_HI8:
|
||||||
|
begin
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.read(b,1);
|
||||||
|
w:=b or (objreloc.HiByte shl 8);
|
||||||
|
Inc(w,target);
|
||||||
|
b:=Byte(w shr 8);
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.write(b,1);
|
||||||
|
end;
|
||||||
|
RELOC_ABSOLUTE_LO8:
|
||||||
|
begin
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.read(b,1);
|
||||||
|
w:=b or (objreloc.HiByte shl 8);
|
||||||
|
Inc(w,target);
|
||||||
|
b:=Byte(w);
|
||||||
|
objsec.Data.seek(objreloc.DataOffset);
|
||||||
|
objsec.Data.write(b,1);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
internalerror(2020060303);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TIntelHexExeOutput.create;
|
constructor TIntelHexExeOutput.create;
|
||||||
|
Loading…
Reference in New Issue
Block a user