* use a case statement, instead of 'if', based on the OMF record type in

TOmfObjInput.ReadLEDataAndFixups. This is to allow (in the future) handling of
  LIDATA records and FIXUPP records without preceding LEDATA/LIDATA. No
  functional changes in this commit.

git-svn-id: trunk@39166 -
This commit is contained in:
nickysn 2018-06-04 13:11:55 +00:00
parent 43d7b23555
commit 002b116322

View File

@ -1498,57 +1498,62 @@ implementation
Thread: TOmfSubRecord_THREAD; Thread: TOmfSubRecord_THREAD;
begin begin
Result:=False; Result:=False;
if not (RawRec.RecordType in [RT_LEDATA,RT_LEDATA32]) then case RawRec.RecordType of
internalerror(2015040301); RT_LEDATA,RT_LEDATA32:
Is32Bit:=RawRec.RecordType=RT_LEDATA32; begin
NextOfs:=RawRec.ReadIndexedRef(0,SegmentIndex); Is32Bit:=RawRec.RecordType=RT_LEDATA32;
if Is32Bit then NextOfs:=RawRec.ReadIndexedRef(0,SegmentIndex);
begin if Is32Bit then
if (NextOfs+3)>=RawRec.RecordLength then begin
internalerror(2015040504); if (NextOfs+3)>=RawRec.RecordLength then
EnumeratedDataOffset := RawRec.RawData[NextOfs]+ internalerror(2015040504);
(RawRec.RawData[NextOfs+1] shl 8)+ EnumeratedDataOffset := RawRec.RawData[NextOfs]+
(RawRec.RawData[NextOfs+2] shl 16)+ (RawRec.RawData[NextOfs+1] shl 8)+
(RawRec.RawData[NextOfs+3] shl 24); (RawRec.RawData[NextOfs+2] shl 16)+
Inc(NextOfs,4); (RawRec.RawData[NextOfs+3] shl 24);
end Inc(NextOfs,4);
else end
begin else
if (NextOfs+1)>=RawRec.RecordLength then begin
internalerror(2015040504); if (NextOfs+1)>=RawRec.RecordLength then
EnumeratedDataOffset := RawRec.RawData[NextOfs]+ internalerror(2015040504);
(RawRec.RawData[NextOfs+1] shl 8); EnumeratedDataOffset := RawRec.RawData[NextOfs]+
Inc(NextOfs,2); (RawRec.RawData[NextOfs+1] shl 8);
end; Inc(NextOfs,2);
BlockLength:=RawRec.RecordLength-NextOfs-1; end;
if BlockLength<0 then BlockLength:=RawRec.RecordLength-NextOfs-1;
internalerror(2015060501); if BlockLength<0 then
if BlockLength>1024 then internalerror(2015060501);
begin if BlockLength>1024 then
InputError('LEDATA contains more than 1024 bytes of data'); begin
exit; InputError('LEDATA contains more than 1024 bytes of data');
end; exit;
end;
if (SegmentIndex<1) or (SegmentIndex>objdata.ObjSectionList.Count) then if (SegmentIndex<1) or (SegmentIndex>objdata.ObjSectionList.Count) then
begin begin
InputError('Segment index in LEDATA field is out of range'); InputError('Segment index in LEDATA field is out of range');
exit; exit;
end; end;
objsec:=TOmfObjSection(objdata.ObjSectionList[SegmentIndex-1]); objsec:=TOmfObjSection(objdata.ObjSectionList[SegmentIndex-1]);
objsec.SecOptions:=objsec.SecOptions+[oso_Data]; objsec.SecOptions:=objsec.SecOptions+[oso_Data];
if (objsec.Data.Size>EnumeratedDataOffset) then if (objsec.Data.Size>EnumeratedDataOffset) then
begin begin
InputError('LEDATA enumerated data offset field out of sequence'); InputError('LEDATA enumerated data offset field out of sequence');
exit; exit;
end; end;
if (EnumeratedDataOffset+BlockLength)>objsec.Size then if (EnumeratedDataOffset+BlockLength)>objsec.Size then
begin begin
InputError('LEDATA goes beyond the segment size declared in the SEGDEF record'); InputError('LEDATA goes beyond the segment size declared in the SEGDEF record');
exit; exit;
end; end;
objsec.Data.seek(EnumeratedDataOffset); objsec.Data.seek(EnumeratedDataOffset);
objsec.Data.write(RawRec.RawData[NextOfs],BlockLength); objsec.Data.write(RawRec.RawData[NextOfs],BlockLength);
end;
else
internalerror(2015040301);
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 while PeekNextRecordType in [RT_FIXUPP,RT_FIXUPP32] do