+ also write the relocations in the .rel internal obj writer

git-svn-id: trunk@45268 -
This commit is contained in:
nickysn 2020-05-05 19:51:44 +00:00
parent f2b924573a
commit 5193e8332c

View File

@ -56,12 +56,15 @@ interface
{ TRelRelocation } { TRelRelocation }
TRelRelocation = class(TObjRelocation) TRelRelocation = class(TObjRelocation)
private
function GetSecOrSymIdx: longint;
public public
RelFlags: TRelRelocationFlags; RelFlags: TRelRelocationFlags;
constructor CreateSymbol(ADataOffset:TObjSectionOfs;s:TObjSymbol;Atyp:TObjRelocationType); constructor CreateSymbol(ADataOffset:TObjSectionOfs;s:TObjSymbol;Atyp:TObjRelocationType);
constructor CreateSection(ADataOffset:TObjSectionOfs;aobjsec:TObjSection;Atyp:TObjRelocationType); constructor CreateSection(ADataOffset:TObjSectionOfs;aobjsec:TObjSection;Atyp:TObjRelocationType);
function EncodeFlags: string; function EncodeFlags: string;
property SecOrSymIdx: longint read GetSecOrSymIdx;
end; end;
{ TRelObjData } { TRelObjData }
@ -112,6 +115,16 @@ implementation
TRelRelocation TRelRelocation
*****************************************************************************} *****************************************************************************}
function TRelRelocation.GetSecOrSymIdx: longint;
begin
if assigned(symbol) then
result:=symbol.symidx
else if assigned(objsection) then
result:=objsection.SecSymIdx
else
internalerror(2020050502);
end;
constructor TRelRelocation.CreateSymbol(ADataOffset: TObjSectionOfs; s: TObjSymbol; Atyp: TObjRelocationType); constructor TRelRelocation.CreateSymbol(ADataOffset: TObjSectionOfs; s: TObjSymbol; Atyp: TObjRelocationType);
begin begin
inherited; inherited;
@ -305,6 +318,7 @@ implementation
ChunkFixupStart,ChunkFixupEnd: Integer; ChunkFixupStart,ChunkFixupEnd: Integer;
s: ansistring; s: ansistring;
buf: array [0..MaxChunkSize-1] of Byte; buf: array [0..MaxChunkSize-1] of Byte;
reloc: TRelRelocation;
begin begin
if oso_data in sec.SecOptions then if oso_data in sec.SecOptions then
begin begin
@ -336,7 +350,16 @@ implementation
for i:=0 to ChunkLen-1 do for i:=0 to ChunkLen-1 do
s:=s+' '+HexStr(buf[i],2); s:=s+' '+HexStr(buf[i],2);
writeLine(s); writeLine(s);
writeLine('R 00 00 '+HexStr(Byte(sec.SecSymIdx),2)+' '+HexStr(Byte(sec.SecSymIdx shr 8),2)); s:='R 00 00 '+HexStr(Byte(sec.SecSymIdx),2)+' '+HexStr(Byte(sec.SecSymIdx shr 8),2);
if ChunkFixupEnd>=ChunkFixupStart then
begin
for i:=ChunkFixupStart to ChunkFixupEnd do
begin
reloc:=TRelRelocation(sec.ObjRelocations[i]);
s:=s+' '+reloc.EncodeFlags+' '+HexStr(reloc.DataOffset-ChunkStart+2,2)+' '+HexStr(Byte(reloc.SecOrSymIdx),2)+' '+HexStr(Byte(reloc.SecOrSymIdx shr 8),2);
end;
end;
writeLine(s);
{ prepare next chunk } { prepare next chunk }
Inc(ChunkStart, ChunkLen); Inc(ChunkStart, ChunkLen);
ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart); ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart);