mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 16:09:17 +02:00
+ support OMF FIXUPP records, containing only THREAD subrecords to occur without
a preceding LEDATA or LIDATA record (this is allowed by the OMF spec) git-svn-id: trunk@39169 -
This commit is contained in:
parent
49c97d1152
commit
e410a0aefb
@ -1493,9 +1493,10 @@ implementation
|
|||||||
EnumeratedDataOffset: DWord;
|
EnumeratedDataOffset: DWord;
|
||||||
BlockLength: Integer;
|
BlockLength: Integer;
|
||||||
objsec: TOmfObjSection;
|
objsec: TOmfObjSection;
|
||||||
FixupRawRec: TOmfRawRecord;
|
FixupRawRec: TOmfRawRecord=nil;
|
||||||
Fixup: TOmfSubRecord_FIXUP;
|
Fixup: TOmfSubRecord_FIXUP;
|
||||||
Thread: TOmfSubRecord_THREAD;
|
Thread: TOmfSubRecord_THREAD;
|
||||||
|
FixuppWithoutLeOrLiData: Boolean=False;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
case RawRec.RecordType of
|
case RawRec.RecordType of
|
||||||
@ -1551,12 +1552,23 @@ implementation
|
|||||||
objsec.Data.seek(EnumeratedDataOffset);
|
objsec.Data.seek(EnumeratedDataOffset);
|
||||||
objsec.Data.write(RawRec.RawData[NextOfs],BlockLength);
|
objsec.Data.write(RawRec.RawData[NextOfs],BlockLength);
|
||||||
end;
|
end;
|
||||||
|
RT_FIXUPP,RT_FIXUPP32:
|
||||||
|
begin
|
||||||
|
FixuppWithoutLeOrLiData:=True;
|
||||||
|
{ a hack, used to indicate, that we must process this record }
|
||||||
|
{ (RawRec) first in the FIXUPP record processing loop that follows }
|
||||||
|
FixupRawRec:=RawRec;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
internalerror(2015040301);
|
internalerror(2015040301);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ also read all the FIXUPP records that may follow }
|
{ also read all the FIXUPP records that may follow; }
|
||||||
while PeekNextRecordType in [RT_FIXUPP,RT_FIXUPP32] do
|
{ (FixupRawRec=RawRec) indicates that we must process RawRec first, but }
|
||||||
|
{ without freeing it }
|
||||||
|
while (FixupRawRec=RawRec) or (PeekNextRecordType in [RT_FIXUPP,RT_FIXUPP32]) do
|
||||||
|
begin
|
||||||
|
if FixupRawRec<>RawRec then
|
||||||
begin
|
begin
|
||||||
FixupRawRec:=TOmfRawRecord.Create;
|
FixupRawRec:=TOmfRawRecord.Create;
|
||||||
FixupRawRec.ReadFrom(FReader);
|
FixupRawRec.ReadFrom(FReader);
|
||||||
@ -1566,6 +1578,7 @@ implementation
|
|||||||
FixupRawRec.Free;
|
FixupRawRec.Free;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
NextOfs:=0;
|
NextOfs:=0;
|
||||||
Thread:=TOmfSubRecord_THREAD.Create;
|
Thread:=TOmfSubRecord_THREAD.Create;
|
||||||
Fixup:=TOmfSubRecord_FIXUP.Create;
|
Fixup:=TOmfSubRecord_FIXUP.Create;
|
||||||
@ -1576,6 +1589,15 @@ implementation
|
|||||||
if (FixupRawRec.RawData[NextOfs] and $80)<>0 then
|
if (FixupRawRec.RawData[NextOfs] and $80)<>0 then
|
||||||
begin
|
begin
|
||||||
{ FIXUP subrecord }
|
{ FIXUP subrecord }
|
||||||
|
if FixuppWithoutLeOrLiData then
|
||||||
|
begin
|
||||||
|
InputError('FIXUP subrecord without previous LEDATA or LIDATA record');
|
||||||
|
Fixup.Free;
|
||||||
|
Thread.Free;
|
||||||
|
if FixupRawRec<>RawRec then
|
||||||
|
FixupRawRec.Free;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
NextOfs:=Fixup.ReadAt(FixupRawRec,NextOfs);
|
NextOfs:=Fixup.ReadAt(FixupRawRec,NextOfs);
|
||||||
Fixup.ResolveByThread(FFixupThreads);
|
Fixup.ResolveByThread(FFixupThreads);
|
||||||
ImportOmfFixup(objdata,objsec,Fixup);
|
ImportOmfFixup(objdata,objsec,Fixup);
|
||||||
@ -1589,7 +1611,12 @@ implementation
|
|||||||
end;
|
end;
|
||||||
Fixup.Free;
|
Fixup.Free;
|
||||||
Thread.Free;
|
Thread.Free;
|
||||||
|
if FixupRawRec<>RawRec then
|
||||||
FixupRawRec.Free;
|
FixupRawRec.Free;
|
||||||
|
{ always set it to null, so that we read the next record on the next }
|
||||||
|
{ loop iteration (this ensures that FixupRawRec<>RawRec, without }
|
||||||
|
{ freeing RawRec) }
|
||||||
|
FixupRawRec:=nil;
|
||||||
end;
|
end;
|
||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
@ -1959,7 +1986,8 @@ implementation
|
|||||||
RT_PUBDEF,RT_PUBDEF32:
|
RT_PUBDEF,RT_PUBDEF32:
|
||||||
if not ReadPubDef(FRawRecord,objdata) then
|
if not ReadPubDef(FRawRecord,objdata) then
|
||||||
exit;
|
exit;
|
||||||
RT_LEDATA,RT_LEDATA32:
|
RT_LEDATA,RT_LEDATA32,
|
||||||
|
RT_FIXUPP,RT_FIXUPP32:
|
||||||
if not ReadLEDataAndFixups(FRawRecord,objdata) then
|
if not ReadLEDataAndFixups(FRawRecord,objdata) then
|
||||||
exit;
|
exit;
|
||||||
RT_LIDATA,RT_LIDATA32:
|
RT_LIDATA,RT_LIDATA32:
|
||||||
@ -1967,11 +1995,6 @@ implementation
|
|||||||
InputError('LIDATA records are not supported');
|
InputError('LIDATA records are not supported');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
RT_FIXUPP,RT_FIXUPP32:
|
|
||||||
begin
|
|
||||||
InputError('FIXUPP record is invalid, because it does not follow a LEDATA or LIDATA record');
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
RT_MODEND,RT_MODEND32:
|
RT_MODEND,RT_MODEND32:
|
||||||
if not ReadModEnd(FRawRecord,objdata) then
|
if not ReadModEnd(FRawRecord,objdata) then
|
||||||
exit;
|
exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user