Browse Source

+ 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 -

nickysn 9 years ago
parent
commit
0d48e5f6c7
2 changed files with 53 additions and 13 deletions
  1. 1 0
      compiler/ogbase.pas
  2. 52 13
      compiler/ogomf.pas

+ 1 - 0
compiler/ogbase.pas

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

+ 52 - 13
compiler/ogomf.pas

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