Browse Source

+ added support for 32-bit offset OMF relocations (fltOffset32) in the OMF internal linker

git-svn-id: trunk@32927 -
nickysn 9 years ago
parent
commit
02a6b77e32
1 changed files with 52 additions and 3 deletions
  1. 52 3
      compiler/ogomf.pas

+ 52 - 3
compiler/ogomf.pas

@@ -1555,6 +1555,13 @@ implementation
                   fmSelfRelative:
                     RelocType:=RELOC_RELATIVE16;
                 end;
+              fltOffset32:
+                case Fixup.Mode of
+                  fmSegmentRelative:
+                    RelocType:=RELOC_ABSOLUTE32;
+                  fmSelfRelative:
+                    RelocType:=RELOC_RELATIVE32;
+                end;
               fltBase:
                 case Fixup.Mode of
                   fmSegmentRelative:
@@ -1606,6 +1613,13 @@ implementation
                   fmSelfRelative:
                     RelocType:=RELOC_RELATIVE16;
                 end;
+              fltOffset32:
+                case Fixup.Mode of
+                  fmSegmentRelative:
+                    RelocType:=RELOC_ABSOLUTE32;
+                  fmSelfRelative:
+                    RelocType:=RELOC_RELATIVE32;
+                end;
               fltBase:
                 case Fixup.Mode of
                   fmSegmentRelative:
@@ -1657,6 +1671,13 @@ implementation
                   fmSelfRelative:
                     RelocType:=RELOC_RELATIVE16;
                 end;
+              fltOffset32:
+                case Fixup.Mode of
+                  fmSegmentRelative:
+                    RelocType:=RELOC_ABSOLUTE32;
+                  fmSelfRelative:
+                    RelocType:=RELOC_RELATIVE32;
+                end;
               fltBase:
                 case Fixup.Mode of
                   fmSegmentRelative:
@@ -2408,6 +2429,19 @@ implementation
             omfsec.Data.write(w,2);
           end;
 
+        procedure FixupOffset32;
+          var
+            lw: LongWord;
+          begin
+            omfsec.Data.seek(objreloc.DataOffset);
+            omfsec.Data.read(lw,4);
+            lw:=LEtoN(lw);
+            Inc(lw,fixupamount);
+            lw:=LEtoN(lw);
+            omfsec.Data.seek(objreloc.DataOffset);
+            omfsec.Data.write(lw,4);
+          end;
+
         procedure FixupBase(DataOffset: LongWord);
           var
             w: Word;
@@ -2437,10 +2471,12 @@ implementation
                 else
                   framebase:=TOmfObjSection(objreloc.symbol.objsection).MZExeUnifiedLogicalSegment.MemBasePos;
                 case objreloc.typ of
-                  RELOC_ABSOLUTE16,RELOC_SEG,RELOC_FARPTR:
+                  RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG,RELOC_FARPTR:
                     fixupamount:=target-framebase;
                   RELOC_RELATIVE16,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
                     fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
+                  RELOC_RELATIVE32:
+                    fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-4;
                   else
                     internalerror(2015082402);
                 end;
@@ -2448,6 +2484,9 @@ implementation
                   RELOC_ABSOLUTE16,
                   RELOC_RELATIVE16:
                     FixupOffset;
+                  RELOC_ABSOLUTE32,
+                  RELOC_RELATIVE32:
+                    FixupOffset32;
                   RELOC_SEG,
                   RELOC_SEGREL:
                     FixupBase(objreloc.DataOffset);
@@ -2469,10 +2508,12 @@ implementation
                 else
                   framebase:=TOmfObjSection(objreloc.objsection).MZExeUnifiedLogicalSegment.MemBasePos;
                 case objreloc.typ of
-                  RELOC_ABSOLUTE16,RELOC_SEG,RELOC_FARPTR:
+                  RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG,RELOC_FARPTR:
                     fixupamount:=target-framebase;
                   RELOC_RELATIVE16,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
                     fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
+                  RELOC_RELATIVE32:
+                    fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-4;
                   else
                     internalerror(2015082405);
                 end;
@@ -2480,6 +2521,9 @@ implementation
                   RELOC_ABSOLUTE16,
                   RELOC_RELATIVE16:
                     FixupOffset;
+                  RELOC_ABSOLUTE32,
+                  RELOC_RELATIVE32:
+                    FixupOffset32;
                   RELOC_SEG,
                   RELOC_SEGREL:
                     FixupBase(objreloc.DataOffset);
@@ -2502,10 +2546,12 @@ implementation
                 else
                   framebase:=target_group.MemPos;
                 case objreloc.typ of
-                  RELOC_ABSOLUTE16,RELOC_SEG,RELOC_FARPTR:
+                  RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG,RELOC_FARPTR:
                     fixupamount:=target-framebase;
                   RELOC_RELATIVE16,RELOC_SEGREL,RELOC_FARPTR_RELATIVEOFFSET:
                     fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-2;
+                  RELOC_RELATIVE32:
+                    fixupamount:=target-(omfsec.MemPos+objreloc.DataOffset)-4;
                   else
                     internalerror(2015111202);
                 end;
@@ -2513,6 +2559,9 @@ implementation
                   RELOC_ABSOLUTE16,
                   RELOC_RELATIVE16:
                     FixupOffset;
+                  RELOC_ABSOLUTE32,
+                  RELOC_RELATIVE32:
+                    FixupOffset32;
                   RELOC_SEG,
                   RELOC_SEGREL:
                     FixupBase(objreloc.DataOffset);