mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 13:11:06 +02:00
+ support segment relocations in the omf writer
git-svn-id: trunk@30600 -
This commit is contained in:
parent
65a69129c5
commit
a7e059c875
@ -68,6 +68,8 @@ interface
|
||||
{$endif i386}
|
||||
{$ifdef i8086}
|
||||
RELOC_FARPTR,
|
||||
RELOC_SEG,
|
||||
RELOC_SEGREL,
|
||||
{$endif i8086}
|
||||
{$ifdef arm}
|
||||
RELOC_RELATIVE_24,
|
||||
|
@ -154,34 +154,63 @@ implementation
|
||||
if ObjSection<>nil then
|
||||
begin
|
||||
FOmfFixup.LocationOffset:=DataOffset;
|
||||
FOmfFixup.LocationType:=fltOffset;
|
||||
if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
|
||||
FOmfFixup.LocationType:=fltOffset
|
||||
else if typ in [RELOC_SEG,RELOC_SEGREL] then
|
||||
FOmfFixup.LocationType:=fltBase
|
||||
else
|
||||
internalerror(2015041501);
|
||||
FOmfFixup.FrameDeterminedByThread:=False;
|
||||
FOmfFixup.TargetDeterminedByThread:=False;
|
||||
if typ=RELOC_ABSOLUTE then
|
||||
if typ in [RELOC_ABSOLUTE,RELOC_SEG] then
|
||||
FOmfFixup.Mode:=fmSegmentRelative
|
||||
else if typ=RELOC_RELATIVE then
|
||||
else if typ in [RELOC_RELATIVE,RELOC_SEGREL] then
|
||||
FOmfFixup.Mode:=fmSelfRelative
|
||||
else
|
||||
internalerror(2015041401);
|
||||
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=ObjSection.Index;
|
||||
if TOmfObjSection(ObjSection).PrimaryGroup<>'' then
|
||||
if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
|
||||
begin
|
||||
FOmfFixup.FrameMethod:=ffmGroupIndex;
|
||||
FOmfFixup.FrameDatum:=GetGroupIndex(TOmfObjSection(ObjSection).PrimaryGroup);
|
||||
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=ObjSection.Index;
|
||||
if TOmfObjSection(ObjSection).PrimaryGroup<>'' then
|
||||
begin
|
||||
FOmfFixup.FrameMethod:=ffmGroupIndex;
|
||||
FOmfFixup.FrameDatum:=GetGroupIndex(TOmfObjSection(ObjSection).PrimaryGroup);
|
||||
end
|
||||
else
|
||||
FOmfFixup.FrameMethod:=ffmTarget;
|
||||
end
|
||||
else
|
||||
FOmfFixup.FrameMethod:=ffmTarget;
|
||||
begin
|
||||
FOmfFixup.FrameMethod:=ffmTarget;
|
||||
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=ObjSection.Index;
|
||||
if TOmfObjSection(ObjSection).PrimaryGroup<>'' then
|
||||
begin
|
||||
FOmfFixup.TargetMethod:=ftmGroupIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=GetGroupIndex(TOmfObjSection(ObjSection).PrimaryGroup);
|
||||
end
|
||||
else
|
||||
begin
|
||||
FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
|
||||
FOmfFixup.TargetDatum:=ObjSection.Index;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else if symbol<>nil then
|
||||
begin
|
||||
FOmfFixup.LocationOffset:=DataOffset;
|
||||
FOmfFixup.LocationType:=fltOffset;
|
||||
if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
|
||||
FOmfFixup.LocationType:=fltOffset
|
||||
else if typ in [RELOC_SEG,RELOC_SEGREL] then
|
||||
FOmfFixup.LocationType:=fltBase
|
||||
else
|
||||
internalerror(2015041501);
|
||||
FOmfFixup.FrameDeterminedByThread:=False;
|
||||
FOmfFixup.TargetDeterminedByThread:=False;
|
||||
if typ=RELOC_ABSOLUTE then
|
||||
if typ in [RELOC_ABSOLUTE,RELOC_SEG] then
|
||||
FOmfFixup.Mode:=fmSegmentRelative
|
||||
else if typ=RELOC_RELATIVE then
|
||||
else if typ in [RELOC_RELATIVE,RELOC_SEGREL] then
|
||||
FOmfFixup.Mode:=fmSelfRelative
|
||||
else
|
||||
internalerror(2015041401);
|
||||
@ -349,6 +378,16 @@ implementation
|
||||
write('nil');
|
||||
Writeln(',',Reloctype,')');}
|
||||
|
||||
{ RELOC_FARPTR = RELOC_ABSOLUTE+RELOC_SEG }
|
||||
if Reloctype=RELOC_FARPTR then
|
||||
begin
|
||||
if len<>4 then
|
||||
internalerror(2015041502);
|
||||
writeReloc(Data,2,p,RELOC_ABSOLUTE);
|
||||
writeReloc(0,2,p,RELOC_SEG);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if CurrObjSec=nil then
|
||||
internalerror(200403072);
|
||||
objreloc:=nil;
|
||||
|
@ -2521,6 +2521,15 @@ implementation
|
||||
begin
|
||||
currval:=oper[opidx]^.ref^.offset;
|
||||
currsym:=ObjData.symbolref(oper[opidx]^.ref^.symbol);
|
||||
{$ifdef i8086}
|
||||
if oper[opidx]^.ref^.refaddr=addr_seg then
|
||||
begin
|
||||
currrelreloc:=RELOC_SEGREL;
|
||||
currabsreloc:=RELOC_SEG;
|
||||
currabsreloc32:=RELOC_SEG;
|
||||
end
|
||||
else
|
||||
{$endif i8086}
|
||||
{$ifdef i386}
|
||||
if (oper[opidx]^.ref^.refaddr=addr_pic) and
|
||||
(tf_pic_uses_got in target_info.flags) then
|
||||
|
Loading…
Reference in New Issue
Block a user