From 0d48e5f6c7e191be332c0eb051afef1ef349bd91 Mon Sep 17 00:00:00 2001 From: nickysn Date: Mon, 16 Nov 2015 14:51:05 +0000 Subject: [PATCH] + 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 - --- compiler/ogbase.pas | 1 + compiler/ogomf.pas | 65 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index acaabcdca6..c61def841e 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -70,6 +70,7 @@ interface RELOC_ABSOLUTE32, RELOC_RELATIVE32, RELOC_FARPTR, + RELOC_FARPTR_RELATIVEOFFSET, RELOC_SEG, RELOC_SEGREL, RELOC_DGROUP, diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index 2bb09aa732..1a6fc93e6e 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -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;