2
0
Эх сурвалжийг харах

+ introduced a new type TRelocDataInt for use as the 'data' parameter for
TObjData.writeReloc; on i8086 it was changed to longint to allow using 32-bit
relocations
+ added support for writing 32-bit OMF relocations

git-svn-id: trunk@32936 -

nickysn 9 жил өмнө
parent
commit
db5e67c3fe

+ 9 - 1
compiler/ogbase.pas

@@ -307,6 +307,14 @@ interface
        Owner: TObjData;
      end;
 
+{$ifdef i8086}
+     { on i8086 we use a longint, to support 32-bit relocations as well (e.g.
+       for allowing 386+ instructions with 32-bit addresses in inline asm code) }
+     TRelocDataInt = longint;
+{$else i8086}
+     TRelocDataInt = aint;
+{$endif i8086}
+
      TObjData = class(TLinkedListItem)
      private
        FCurrObjSec : TObjSection;
@@ -357,7 +365,7 @@ interface
        procedure alloc(len:aword);
        procedure allocalign(len:shortint);
        procedure writebytes(const Data;len:aword);
-       procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);virtual;abstract;
+       procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);virtual;abstract;
        procedure beforealloc;virtual;
        procedure beforewrite;virtual;
        procedure afteralloc;virtual;

+ 18 - 12
compiler/ogomf.pas

@@ -105,7 +105,7 @@ interface
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
         function createsection(atype:TAsmSectionType;const aname:string='';aorder:TAsmSectionOrder=secorder_default):TObjSection;override;
         function reffardatasection:TObjSection;
-        procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
+        procedure writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
       end;
 
       { TOmfObjOutput }
@@ -358,21 +358,23 @@ implementation
         if ObjSection<>nil then
           begin
             FOmfFixup.LocationOffset:=DataOffset;
-            if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_RELATIVE16] then
               FOmfFixup.LocationType:=fltOffset
+            else if typ in [RELOC_ABSOLUTE32,RELOC_RELATIVE32] then
+              FOmfFixup.LocationType:=fltOffset32
             else if typ in [RELOC_SEG,RELOC_SEGREL] then
               FOmfFixup.LocationType:=fltBase
             else
               internalerror(2015041501);
             FOmfFixup.FrameDeterminedByThread:=False;
             FOmfFixup.TargetDeterminedByThread:=False;
-            if typ in [RELOC_ABSOLUTE,RELOC_SEG] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG] then
               FOmfFixup.Mode:=fmSegmentRelative
-            else if typ in [RELOC_RELATIVE,RELOC_SEGREL] then
+            else if typ in [RELOC_RELATIVE16,RELOC_RELATIVE32,RELOC_SEGREL] then
               FOmfFixup.Mode:=fmSelfRelative
             else
               internalerror(2015041401);
-            if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_RELATIVE16,RELOC_RELATIVE32] then
               begin
                 FOmfFixup.TargetMethod:=ftmSegmentIndexNoDisp;
                 FOmfFixup.TargetDatum:=ObjSection.Index;
@@ -402,17 +404,19 @@ implementation
         else if symbol<>nil then
           begin
             FOmfFixup.LocationOffset:=DataOffset;
-            if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_RELATIVE16] then
               FOmfFixup.LocationType:=fltOffset
+            else if typ in [RELOC_ABSOLUTE32,RELOC_RELATIVE32] then
+              FOmfFixup.LocationType:=fltOffset32
             else if typ in [RELOC_SEG,RELOC_SEGREL] then
               FOmfFixup.LocationType:=fltBase
             else
               internalerror(2015041501);
             FOmfFixup.FrameDeterminedByThread:=False;
             FOmfFixup.TargetDeterminedByThread:=False;
-            if typ in [RELOC_ABSOLUTE,RELOC_SEG] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG] then
               FOmfFixup.Mode:=fmSegmentRelative
-            else if typ in [RELOC_RELATIVE,RELOC_SEGREL] then
+            else if typ in [RELOC_RELATIVE16,RELOC_RELATIVE32,RELOC_SEGREL] then
               FOmfFixup.Mode:=fmSelfRelative
             else
               internalerror(2015041401);
@@ -423,17 +427,19 @@ implementation
         else if group<>nil then
           begin
             FOmfFixup.LocationOffset:=DataOffset;
-            if typ in [RELOC_ABSOLUTE,RELOC_RELATIVE] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_RELATIVE16] then
               FOmfFixup.LocationType:=fltOffset
+            else if typ in [RELOC_ABSOLUTE32,RELOC_RELATIVE32] then
+              FOmfFixup.LocationType:=fltOffset32
             else if typ in [RELOC_SEG,RELOC_SEGREL] then
               FOmfFixup.LocationType:=fltBase
             else
               internalerror(2015041501);
             FOmfFixup.FrameDeterminedByThread:=False;
             FOmfFixup.TargetDeterminedByThread:=False;
-            if typ in [RELOC_ABSOLUTE,RELOC_SEG] then
+            if typ in [RELOC_ABSOLUTE16,RELOC_ABSOLUTE32,RELOC_SEG] then
               FOmfFixup.Mode:=fmSegmentRelative
-            else if typ in [RELOC_RELATIVE,RELOC_SEGREL] then
+            else if typ in [RELOC_RELATIVE16,RELOC_RELATIVE32,RELOC_SEGREL] then
               FOmfFixup.Mode:=fmSelfRelative
             else
               internalerror(2015041401);
@@ -564,7 +570,7 @@ implementation
           end;
       end;
 
-    procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
+    procedure TOmfObjData.writeReloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
       var
         objreloc: TOmfRelocation;
         symaddr: AWord;

+ 1 - 1
compiler/x86/aasmcpu.pas

@@ -2654,7 +2654,7 @@ implementation
            objdata.writebytes(b67,1);
          end;
 
-       procedure objdata_writereloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
+       procedure objdata_writereloc(Data:TRelocDataInt;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
          begin
 {$ifdef i386}
                { Special case of '_GLOBAL_OFFSET_TABLE_'