From 2c1049b5d41dbb051ab3e6fa00164b250fe0af7f Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 4 Jun 2015 23:03:22 +0000 Subject: [PATCH] + read the LEDATA omf records (i.e. the actual section data) git-svn-id: trunk@30975 - --- compiler/ogomf.pas | 70 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index 7afdff724f..6e6a78649c 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -129,6 +129,7 @@ interface function ReadSegDef(RawRec: TOmfRawRecord; objdata:TObjData): Boolean; function ReadGrpDef(RawRec: TOmfRawRecord; objdata:TObjData): Boolean; function ReadExtDef(RawRec: TOmfRawRecord; objdata:TObjData): Boolean; + function ReadLEDataAndFixups(RawRec: TOmfRawRecord; objdata:TObjData): Boolean; property LNames: TOmfOrderedNameCollection read FLNames; property ExtDefs: TFPHashObjectList read FExtDefs; @@ -1050,6 +1051,70 @@ implementation Result:=True; end; + function TOmfObjInput.ReadLEDataAndFixups(RawRec: TOmfRawRecord; objdata: TObjData): Boolean; + var + Is32Bit: Boolean; + NextOfs: Integer; + SegmentIndex: Integer; + EnumeratedDataOffset: DWord; + BlockLength: Integer; + objsec: TOmfObjSection; + begin + Result:=False; + if not (RawRec.RecordType in [RT_LEDATA,RT_LEDATA32]) then + internalerror(2015040301); + Is32Bit:=RawRec.RecordType=RT_LEDATA32; + NextOfs:=RawRec.ReadIndexedRef(0,SegmentIndex); + if Is32Bit then + begin + if (NextOfs+3)>=RawRec.RecordLength then + internalerror(2015040504); + EnumeratedDataOffset := RawRec.RawData[NextOfs]+ + (RawRec.RawData[NextOfs+1] shl 8)+ + (RawRec.RawData[NextOfs+2] shl 16)+ + (RawRec.RawData[NextOfs+3] shl 24); + Inc(NextOfs,4); + end + else + begin + if (NextOfs+1)>=RawRec.RecordLength then + internalerror(2015040504); + EnumeratedDataOffset := RawRec.RawData[NextOfs]+ + (RawRec.RawData[NextOfs+1] shl 8); + Inc(NextOfs,2); + end; + BlockLength:=RawRec.RecordLength-NextOfs-1; + if BlockLength<0 then + internalerror(2015060501); + if BlockLength>1024 then + begin + InputError('LEDATA contains more than 1024 bytes of data'); + exit; + end; + + if (SegmentIndex<1) or (SegmentIndex>objdata.ObjSectionList.Count) then + begin + InputError('Segment index in LEDATA field is out of range'); + exit; + end; + objsec:=TOmfObjSection(objdata.ObjSectionList[SegmentIndex-1]); + + objsec.SecOptions:=objsec.SecOptions+[oso_Data]; + if (objsec.Data.Size<>EnumeratedDataOffset) then + begin + InputError('LEDATA enumerated data offset field out of sequence'); + exit; + end; + if (EnumeratedDataOffset+BlockLength)>objsec.Size then + begin + InputError('LEDATA goes beyond the segment size declared in the SEGDEF record'); + exit; + end; + objsec.Data.write(RawRec.RawData[NextOfs],BlockLength); + {todo: read also the FIXUPP record that may follow} + Result:=True; + end; + constructor TOmfObjInput.create; begin inherited create; @@ -1129,9 +1194,8 @@ implementation {todo} end; RT_LEDATA,RT_LEDATA32: - begin - {todo} - end; + if not ReadLEDataAndFixups(FRawRecord,objdata) then + exit; RT_FIXUPP,RT_FIXUPP32: begin {todo}