+ added support to the omf/i8086-msdos internal linker for omf relocation with

location type 3 (fltFarPointer). This isn't generated by nasm, nor by the
  internal object writer (yet), but may be generated by other
  assemblers/compilers - TASM generates it (tested with it), MASM probably also
  does.

git-svn-id: trunk@32346 -
This commit is contained in:
nickysn 2015-11-16 14:51:05 +00:00
parent 2809e98bf9
commit 0d48e5f6c7
2 changed files with 53 additions and 13 deletions

View File

@ -70,6 +70,7 @@ interface
RELOC_ABSOLUTE32,
RELOC_RELATIVE32,
RELOC_FARPTR,
RELOC_FARPTR_RELATIVEOFFSET,
RELOC_SEG,
RELOC_SEGREL,
RELOC_DGROUP,

View File

@ -1546,6 +1546,13 @@ implementation
fmSelfRelative:
RelocType:=RELOC_SEGREL;
end;
fltFarPointer:
case Fixup.Mode of
fmSegmentRelative:
RelocType:=RELOC_FARPTR;
fmSelfRelative:
RelocType:=RELOC_FARPTR_RELATIVEOFFSET;
end;
end;
if RelocType=RELOC_NONE then
begin
@ -1590,6 +1597,13 @@ implementation
fmSelfRelative:
RelocType:=RELOC_SEGREL;
end;
fltFarPointer:
case Fixup.Mode of
fmSegmentRelative:
RelocType:=RELOC_FARPTR;
fmSelfRelative:
RelocType:=RELOC_FARPTR_RELATIVEOFFSET;
end;
end;
if RelocType=RELOC_NONE then
begin
@ -1634,6 +1648,13 @@ implementation
fmSelfRelative:
RelocType:=RELOC_SEGREL;
end;
fltFarPointer:
case Fixup.Mode of
fmSegmentRelative:
RelocType:=RELOC_FARPTR;
fmSelfRelative:
RelocType:=RELOC_FARPTR_RELATIVEOFFSET;
end;
end;
if RelocType=RELOC_NONE then
begin
@ -2368,19 +2389,19 @@ implementation
omfsec.Data.write(w,2);
end;
procedure FixupBase;
procedure FixupBase(DataOffset: LongWord);
var
w: Word;
begin
omfsec.Data.seek(objreloc.DataOffset);
omfsec.Data.seek(DataOffset);
omfsec.Data.read(w,2);
w:=LEtoN(w);
Inc(w,framebase shr 4);
w:=LEtoN(w);
omfsec.Data.seek(objreloc.DataOffset);
omfsec.Data.seek(DataOffset);
omfsec.Data.write(w,2);
Header.AddRelocation(omfsec.MZExeUnifiedLogicalSegment.MemBasePos shr 4,
omfsec.MemPos+objreloc.DataOffset-omfsec.MZExeUnifiedLogicalSegment.MemBasePos);
omfsec.MemPos+DataOffset-omfsec.MZExeUnifiedLogicalSegment.MemBasePos);
end;
begin
@ -2397,9 +2418,9 @@ implementation
else
framebase:=TOmfObjSection(objreloc.symbol.objsection).MZExeUnifiedLogicalSegment.MemBasePos;
case objreloc.typ of
RELOC_ABSOLUTE,RELOC_SEG:
RELOC_ABSOLUTE,RELOC_SEG,RELOC_FARPTR:
fixupamount:=target-framebase;
RELOC_RELATIVE,RELOC_SEGREL:
RELOC_RELATIVE,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
else
internalerror(2015082402);
@ -2410,7 +2431,13 @@ implementation
FixupOffset;
RELOC_SEG,
RELOC_SEGREL:
FixupBase;
FixupBase(objreloc.DataOffset);
RELOC_FARPTR,
RELOC_FARPTR_RELATIVEOFFSET:
begin
FixupOffset;
FixupBase(objreloc.DataOffset+2);
end;
else
internalerror(2015082403);
end;
@ -2423,9 +2450,9 @@ implementation
else
framebase:=TOmfObjSection(objreloc.objsection).MZExeUnifiedLogicalSegment.MemBasePos;
case objreloc.typ of
RELOC_ABSOLUTE,RELOC_SEG:
RELOC_ABSOLUTE,RELOC_SEG,RELOC_FARPTR:
fixupamount:=target-framebase;
RELOC_RELATIVE,RELOC_SEGREL:
RELOC_RELATIVE,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
else
internalerror(2015082405);
@ -2436,7 +2463,13 @@ implementation
FixupOffset;
RELOC_SEG,
RELOC_SEGREL:
FixupBase;
FixupBase(objreloc.DataOffset);
RELOC_FARPTR,
RELOC_FARPTR_RELATIVEOFFSET:
begin
FixupOffset;
FixupBase(objreloc.DataOffset+2);
end;
else
internalerror(2015082406);
end;
@ -2450,9 +2483,9 @@ implementation
else
framebase:=target_group.MemPos;
case objreloc.typ of
RELOC_ABSOLUTE,RELOC_SEG:
RELOC_ABSOLUTE,RELOC_SEG,RELOC_FARPTR:
fixupamount:=target-framebase;
RELOC_RELATIVE,RELOC_SEGREL:
RELOC_RELATIVE,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
else
internalerror(2015111202);
@ -2463,7 +2496,13 @@ implementation
FixupOffset;
RELOC_SEG,
RELOC_SEGREL:
FixupBase;
FixupBase(objreloc.DataOffset);
RELOC_FARPTR,
RELOC_FARPTR_RELATIVEOFFSET:
begin
FixupOffset;
FixupBase(objreloc.DataOffset+2);
end;
else
internalerror(2015111203);
end;