mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:49:09 +02:00
* when splitting the section data in chunks, make sure fixups never cross chunk boundaries
git-svn-id: trunk@30679 -
This commit is contained in:
parent
32e0eca0dc
commit
ae04eb258b
@ -546,6 +546,8 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if sec.Data=nil then
|
if sec.Data=nil then
|
||||||
internalerror(200403073);
|
internalerror(200403073);
|
||||||
|
for I:=0 to sec.ObjRelocations.Count-1 do
|
||||||
|
TOmfRelocation(sec.ObjRelocations[I]).BuildOmfFixup;
|
||||||
SegIndex:=Segments.FindIndexOf(sec.Name);
|
SegIndex:=Segments.FindIndexOf(sec.Name);
|
||||||
RawRecord:=TOmfRawRecord.Create;
|
RawRecord:=TOmfRawRecord.Create;
|
||||||
sec.data.seek(0);
|
sec.data.seek(0);
|
||||||
@ -555,6 +557,18 @@ implementation
|
|||||||
ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart);
|
ChunkLen:=Min(MaxChunkSize, sec.Data.size-ChunkStart);
|
||||||
while ChunkLen>0 do
|
while ChunkLen>0 do
|
||||||
begin
|
begin
|
||||||
|
{ find last fixup in the chunk }
|
||||||
|
while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and
|
||||||
|
(TOmfRelocation(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
|
||||||
|
((TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset+
|
||||||
|
TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd]).OmfFixup.LocationSize)>(ChunkStart+ChunkLen)) then
|
||||||
|
begin
|
||||||
|
ChunkLen:=TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd]).DataOffset-ChunkStart;
|
||||||
|
Dec(ChunkFixupEnd);
|
||||||
|
end;
|
||||||
{ write LEDATA record }
|
{ write LEDATA record }
|
||||||
RawRecord.RecordType:=RT_LEDATA;
|
RawRecord.RecordType:=RT_LEDATA;
|
||||||
NextOfs:=RawRecord.WriteIndexedRef(0,SegIndex);
|
NextOfs:=RawRecord.WriteIndexedRef(0,SegIndex);
|
||||||
@ -567,16 +581,12 @@ implementation
|
|||||||
RawRecord.CalculateChecksumByte;
|
RawRecord.CalculateChecksumByte;
|
||||||
RawRecord.WriteTo(FWriter);
|
RawRecord.WriteTo(FWriter);
|
||||||
{ write FIXUPP record }
|
{ write FIXUPP record }
|
||||||
while (ChunkFixupEnd<(sec.ObjRelocations.Count-1)) and
|
|
||||||
(TOmfRelocation(sec.ObjRelocations[ChunkFixupEnd+1]).DataOffset<(ChunkStart+ChunkLen)) do
|
|
||||||
inc(ChunkFixupEnd);
|
|
||||||
if ChunkFixupEnd>=ChunkFixupStart then
|
if ChunkFixupEnd>=ChunkFixupStart then
|
||||||
begin
|
begin
|
||||||
RawRecord.RecordType:=RT_FIXUPP;
|
RawRecord.RecordType:=RT_FIXUPP;
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user