summaryrefslogtreecommitdiff
path: root/compiler/ogrel.pas
diff options
context:
space:
mode:
authornickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-05-05 00:06:11 +0000
committernickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-05-05 00:06:11 +0000
commitaa2eb9927752c7763b5b13991a49750fd7a38394 (patch)
tree357699dd953b1ddbc7ffcde773f94de7fa9871a2 /compiler/ogrel.pas
parent67d8bc0ed43dccbc491060e2b8bc53e6c8a42424 (diff)
downloadfpc-aa2eb9927752c7763b5b13991a49750fd7a38394.tar.gz
+ write the section data in the .rel internal object writer (relocations aren't written, yet)
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@45259 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/ogrel.pas')
-rw-r--r--compiler/ogrel.pas54
1 files changed, 54 insertions, 0 deletions
diff --git a/compiler/ogrel.pas b/compiler/ogrel.pas
index 4a5b629aa0..6a7dd9ab76 100644
--- a/compiler/ogrel.pas
+++ b/compiler/ogrel.pas
@@ -53,6 +53,7 @@ interface
private
procedure writeString(const S: ansistring);
procedure writeLine(const S: ansistring);
+ procedure WriteAreaContentAndRelocations(sec: TObjSection);
protected
function writeData(Data:TObjData):boolean;override;
public
@@ -217,6 +218,54 @@ implementation
writeString(S+#10)
end;
+ procedure TRelObjOutput.WriteAreaContentAndRelocations(sec: TObjSection);
+ const
+ MaxChunkSize=14;
+ var
+ ChunkStart,ChunkLen, i: LongWord;
+ ChunkFixupStart,ChunkFixupEnd: Integer;
+ s: ansistring;
+ buf: array [0..MaxChunkSize-1] of Byte;
+ begin
+ if oso_data in sec.SecOptions then
+ begin
+ if sec.Data=nil then
+ internalerror(200403073);
+ sec.data.seek(0);
+ ChunkFixupStart:=0;
+ ChunkFixupEnd:=-1;
+ ChunkStart:=0;
+ ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart);
+ while ChunkLen>0 do
+ begin
+ { find last fixup in the chunk }
+ while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and
+ (TObjRelocation(sec.ObjRelocations[ChunkFixupEnd+1]).DataOffset<(ChunkStart+ChunkLen)) do
+ inc(ChunkFixupEnd);
+ { check if last chunk is crossing the chunk boundary, and trim ChunkLen if necessary }
+ if (ChunkFixupEnd>=ChunkFixupStart) and
+ ((TObjRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset+
+ TObjRelocation(sec.ObjRelocations[ChunkFixupEnd]).size)>(ChunkStart+ChunkLen)) then
+ begin
+ ChunkLen:=TObjRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset-ChunkStart;
+ Dec(ChunkFixupEnd);
+ end;
+ s:='T '+HexStr(Byte(ChunkStart),2)+' '+HexStr(Byte(ChunkStart shr 8),2);
+ if ChunkLen>SizeOf(buf) then
+ internalerror(2020050501);
+ sec.Data.read(buf,ChunkLen);
+ for i:=0 to ChunkLen-1 do
+ s:=s+' '+HexStr(buf[i],2);
+ writeLine(s);
+ writeLine('R 00 00 '+HexStr(Byte(sec.SecSymIdx),2)+' '+HexStr(Byte(sec.SecSymIdx shr 8),2));
+ { prepare next chunk }
+ Inc(ChunkStart, ChunkLen);
+ ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart);
+ ChunkFixupStart:=ChunkFixupEnd+1;
+ end;
+ end;
+ end;
+
function TRelObjOutput.writeData(Data: TObjData): boolean;
var
global_symbols_count: Integer = 0;
@@ -264,6 +313,11 @@ implementation
end;
end;
end;
+ for i:=0 to Data.ObjSectionList.Count-1 do
+ begin
+ objsec:=TObjSection(Data.ObjSectionList[i]);
+ WriteAreaContentAndRelocations(objsec);
+ end;
result:=true;
end;