mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 04:26:13 +02:00
+ read the LEDATA omf records (i.e. the actual section data)
git-svn-id: trunk@30975 -
This commit is contained in:
parent
d5d84be2a2
commit
2c1049b5d4
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user