Ver Fonte

+ support addr_fardataseg references in the internal asm writer

git-svn-id: trunk@31511 -
nickysn há 10 anos atrás
pai
commit
1487236f29
3 ficheiros alterados com 34 adições e 2 exclusões
  1. 2 0
      compiler/ogbase.pas
  2. 25 1
      compiler/ogomf.pas
  3. 7 1
      compiler/x86/aasmcpu.pas

+ 2 - 0
compiler/ogbase.pas

@@ -72,6 +72,8 @@ interface
          RELOC_SEGREL,
          RELOC_DGROUP,
          RELOC_DGROUPREL,
+         RELOC_FARDATASEG,
+         RELOC_FARDATASEGREL,
 {$endif i8086}
 {$ifdef arm}
          RELOC_RELATIVE_24,

+ 25 - 1
compiler/ogomf.pas

@@ -105,6 +105,7 @@ interface
         function sectiontype2class(atype:TAsmSectiontype):string;
         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;
       end;
 
@@ -551,6 +552,21 @@ implementation
           TOmfObjSection(Result).FPrimaryGroup:='DGROUP';
       end;
 
+    function TOmfObjData.reffardatasection: TObjSection;
+      var
+        secname: string;
+      begin
+        secname:=current_module.modulename^ + '_DATA';
+
+        result:=TObjSection(ObjSectionList.Find(secname));
+        if not assigned(result) then
+          begin
+            result:=CObjSection.create(ObjSectionList,secname,2,[oso_Data,oso_load,oso_write]);
+            result.ObjData:=self;
+            TOmfObjSection(Result).FClassName:='FAR_DATA';
+          end;
+      end;
+
     procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
       var
         objreloc: TOmfRelocation;
@@ -569,7 +585,15 @@ implementation
         if CurrObjSec=nil then
           internalerror(200403072);
         objreloc:=nil;
-        if assigned(p) then
+        if Reloctype in [RELOC_FARDATASEG,RELOC_FARDATASEGREL] then
+          begin
+            if Reloctype=RELOC_FARDATASEG then
+              objreloc:=TOmfRelocation.CreateSection(CurrObjSec.Size,reffardatasection,RELOC_SEG)
+            else
+              objreloc:=TOmfRelocation.CreateSection(CurrObjSec.Size,reffardatasection,RELOC_SEGREL);
+            CurrObjSec.ObjRelocations.Add(objreloc);
+          end
+        else if assigned(p) then
           begin
             { real address of the symbol }
             symaddr:=p.address;

+ 7 - 1
compiler/x86/aasmcpu.pas

@@ -2563,6 +2563,12 @@ implementation
                       currabsreloc:=RELOC_DGROUP;
                       currabsreloc32:=RELOC_DGROUP;
                     end
+                  else if oper[opidx]^.ref^.refaddr=addr_fardataseg then
+                    begin
+                      currrelreloc:=RELOC_FARDATASEGREL;
+                      currabsreloc:=RELOC_FARDATASEG;
+                      currabsreloc32:=RELOC_FARDATASEG;
+                    end
                   else
 {$endif i8086}
 {$ifdef i386}
@@ -2914,7 +2920,7 @@ implementation
 {$endif i8086}
                 if assigned(currsym)
 {$ifdef i8086}
-                   or (currabsreloc=RELOC_DGROUP)
+                   or (currabsreloc in [RELOC_DGROUP,RELOC_FARDATASEG])
 {$endif i8086}
                 then
                  objdata_writereloc(currval,2,currsym,currabsreloc)