Browse Source

* fixed rva writting for section relocs
* fixed section flags for edata and idata

peter 26 years ago
parent
commit
0b82a7dfd6
1 changed files with 40 additions and 21 deletions
  1. 40 21
      compiler/og386cff.pas

+ 40 - 21
compiler/og386cff.pas

@@ -110,7 +110,7 @@ unit og386cff;
           procedure  write(var d;l:longint);
           procedure  write(var d;l:longint);
           procedure  alloc(l:longint);
           procedure  alloc(l:longint);
           procedure  addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
           procedure  addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
-          procedure  addsectionreloc(ofs:longint;sec:tsection);
+          procedure  addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
        end;
        end;
 
 
        pgenericcoffoutput = ^tgenericcoffoutput;
        pgenericcoffoutput = ^tgenericcoffoutput;
@@ -136,7 +136,8 @@ unit og386cff;
          function  text_flags : longint;virtual;
          function  text_flags : longint;virtual;
          function  data_flags : longint;virtual;
          function  data_flags : longint;virtual;
          function  bss_flags : longint;virtual;
          function  bss_flags : longint;virtual;
-         function  info_flags : longint;virtual;
+         function  idata_flags : longint;virtual;
+         function  edata_flags : longint;virtual;
        private
        private
          procedure createsection(sec:tsection);
          procedure createsection(sec:tsection);
          procedure write_relocs(s:pcoffsection);
          procedure write_relocs(s:pcoffsection);
@@ -151,7 +152,6 @@ unit og386cff;
          function text_flags : longint;virtual;
          function text_flags : longint;virtual;
          function data_flags : longint;virtual;
          function data_flags : longint;virtual;
          function bss_flags : longint;virtual;
          function bss_flags : longint;virtual;
-         function info_flags : longint;virtual;
        end;
        end;
 
 
        pwin32coffoutput = ^twin32coffoutput;
        pwin32coffoutput = ^twin32coffoutput;
@@ -160,7 +160,8 @@ unit og386cff;
          function text_flags : longint;virtual;
          function text_flags : longint;virtual;
          function data_flags : longint;virtual;
          function data_flags : longint;virtual;
          function bss_flags : longint;virtual;
          function bss_flags : longint;virtual;
-         function info_flags : longint;virtual;
+         function idata_flags : longint;virtual;
+         function edata_flags : longint;virtual;
        end;
        end;
 
 
   implementation
   implementation
@@ -286,7 +287,7 @@ unit og386cff;
       end;
       end;
 
 
 
 
-    procedure tcoffsection.addsectionreloc(ofs:longint;sec:tsection);
+    procedure tcoffsection.addsectionreloc(ofs:longint;sec:tsection;relative:relative_type);
       var
       var
         r : PReloc;
         r : PReloc;
       begin
       begin
@@ -297,7 +298,7 @@ unit og386cff;
         r^.address:=ofs+mempos;
         r^.address:=ofs+mempos;
         r^.symbol:=nil;
         r^.symbol:=nil;
         r^.section:=sec;
         r^.section:=sec;
-        r^.relative:=relative_false;
+        r^.relative:=relative;
         inc(nrelocs);
         inc(nrelocs);
       end;
       end;
 
 
@@ -384,9 +385,14 @@ unit og386cff;
         bss_flags:=0;
         bss_flags:=0;
       end;
       end;
 
 
-    function tgenericcoffoutput.info_flags : longint;
+    function tgenericcoffoutput.edata_flags : longint;
+      begin
+        edata_flags:=0;
+      end;
+
+    function tgenericcoffoutput.idata_flags : longint;
       begin
       begin
-        info_flags:=0;
+        idata_flags:=0;
       end;
       end;
 
 
 
 
@@ -402,6 +408,14 @@ unit og386cff;
             Aflags:=data_flags;
             Aflags:=data_flags;
           sec_bss :
           sec_bss :
             Aflags:=bss_flags;
             Aflags:=bss_flags;
+          sec_idata2,
+          sec_idata4,
+          sec_idata5,
+          sec_idata6,
+          sec_idata7 :
+            Aflags:=idata_flags;
+          sec_edata :
+            Aflags:=edata_flags;
           else
           else
             Aflags:=0;
             Aflags:=0;
         end;
         end;
@@ -505,7 +519,7 @@ unit og386cff;
                case relative of
                case relative of
                  relative_false :
                  relative_false :
                    begin
                    begin
-                     sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                     sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec,relative_false);
                      inc(data,symaddr);
                      inc(data,symaddr);
                    end;
                    end;
                  relative_true :
                  relative_true :
@@ -516,7 +530,7 @@ unit og386cff;
                    begin
                    begin
                      { don't know if this can happens !! }
                      { don't know if this can happens !! }
                      { does this work ?? }
                      { does this work ?? }
-                     sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                     sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec,relative_rva);
                      inc(data,symaddr);
                      inc(data,symaddr);
                    end;
                    end;
                end;
                end;
@@ -525,7 +539,7 @@ unit og386cff;
              begin
              begin
                writesymbol(p);
                writesymbol(p);
                if (p^.section<>sec_none) and (relative=relative_false) then
                if (p^.section<>sec_none) and (relative=relative_false) then
-                 sects[currsec]^.addsectionreloc(sects[currsec]^.len,p^.section)
+                 sects[currsec]^.addsectionreloc(sects[currsec]^.len,p^.section,relative_false)
                else
                else
                  sects[currsec]^.addsymreloc(sects[currsec]^.len,p,relative);
                  sects[currsec]^.addsymreloc(sects[currsec]^.len,p,relative);
                if not win32 then {seems wrong to me (PM) }
                if not win32 then {seems wrong to me (PM) }
@@ -584,7 +598,7 @@ unit og386cff;
         { when the offset is not 0 then write a relocation, take also the
         { when the offset is not 0 then write a relocation, take also the
           hdrstab into account with the offset }
           hdrstab into account with the offset }
         if reloc then
         if reloc then
-          sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.len-4,s);
+          sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.len-4,s,relative_false);
       end;
       end;
 
 
 
 
@@ -780,10 +794,12 @@ unit og386cff;
         for sec:=low(tsection) to high(tsection) do
         for sec:=low(tsection) to high(tsection) do
          if assigned(sects[sec]) then
          if assigned(sects[sec]) then
           begin
           begin
+{$ifdef EXTDEBUG}
           { check if the section is still the same size }
           { check if the section is still the same size }
             if (sects[sec]^.len<>sects[sec]^.size) then
             if (sects[sec]^.len<>sects[sec]^.size) then
               Comment(V_Warning,'Size of section changed '+tostr(sects[sec]^.size)+'->'+tostr(sects[sec]^.len)+
               Comment(V_Warning,'Size of section changed '+tostr(sects[sec]^.size)+'->'+tostr(sects[sec]^.len)+
                 ' ['+target_asm.secnames[sec]+']');
                 ' ['+target_asm.secnames[sec]+']');
+{$endif EXTDEBUG}
           { fill with zero }
           { fill with zero }
             if sects[sec]^.fillsize>0 then
             if sects[sec]^.fillsize>0 then
              begin
              begin
@@ -904,12 +920,6 @@ unit og386cff;
         bss_flags:=$80;
         bss_flags:=$80;
       end;
       end;
 
 
-    function tdjgppcoffoutput.info_flags : longint;
-      begin
-        writeln('djgpp coff doesn''t support info sections');
-        info_flags:=$40;
-      end;
-
 
 
 {****************************************************************************
 {****************************************************************************
                             Win32coffoutput
                             Win32coffoutput
@@ -936,16 +946,25 @@ unit og386cff;
         bss_flags:=$c0300080;
         bss_flags:=$c0300080;
       end;
       end;
 
 
-    function twin32coffoutput.info_flags : longint;
+    function twin32coffoutput.edata_flags : longint;
       begin
       begin
-        info_flags:=$100a00;
+        edata_flags:=$c0300040;
+      end;
+
+    function twin32coffoutput.idata_flags : longint;
+      begin
+        idata_flags:=$40000000;
       end;
       end;
 
 
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  1999-08-04 00:23:05  florian
+  Revision 1.11  1999-08-11 17:17:38  peter
+    * fixed rva writting for section relocs
+    * fixed section flags for edata and idata
+
+  Revision 1.10  1999/08/04 00:23:05  florian
     * renamed i386asm and i386base to cpuasm and cpubase
     * renamed i386asm and i386base to cpuasm and cpubase
 
 
   Revision 1.9  1999/07/03 00:27:02  peter
   Revision 1.9  1999/07/03 00:27:02  peter