Browse Source

* avoid range check errors with absolute symbols for cpus where addresses are bigger than the registers

git-svn-id: trunk@36361 -
florian 8 years ago
parent
commit
a37237ca11
3 changed files with 43 additions and 3 deletions
  1. 40 0
      compiler/entfile.pas
  2. 1 1
      compiler/ppu.pas
  3. 2 2
      compiler/symsym.pas

+ 40 - 0
compiler/entfile.pas

@@ -268,6 +268,7 @@ type
     function  getqword:qword;
     function getaint:{$ifdef generic_cpu}int64{$else}aint{$endif};
     function getasizeint:{$ifdef generic_cpu}int64{$else}asizeint{$endif};
+    function getpuint:{$ifdef generic_cpu}qword{$else}puint{$endif};
     function getaword:{$ifdef generic_cpu}qword{$else}aword{$endif};
     function  getreal:entryreal;
     function  getrealsize(sizeofreal : longint):entryreal;
@@ -293,6 +294,7 @@ type
     procedure putqword(q:qword);
     procedure putaint(i:aint);
     procedure putasizeint(i:asizeint);
+    procedure putpuint(i:puint);
     procedure putaword(i:aword);
     procedure putreal(d:entryreal);
     procedure putstring(const s:string);
@@ -774,6 +776,38 @@ end;
 end;
 
 
+function tentryfile.getpuint:{$ifdef generic_cpu}qword{$else}puint{$endif};
+{$ifdef generic_cpu}
+var
+header : pentryheader;
+{$endif generic_cpu}
+begin
+{$ifdef generic_cpu}
+  header:=getheaderaddr;
+  if CpuAddrBitSize[tsystemcpu(header^.cpu)]=64 then
+    result:=getqword
+  else if CpuAddrBitSize[tsystemcpu(header^.cpu)]=32 then
+    result:=getdword
+  else if CpuAddrBitSize[tsystemcpu(header^.cpu)]=16 then
+    result:=getbyte
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
+{$else not generic_cpu}
+  case sizeof(puint) of
+    8: result:=getqword;
+    4: result:=getdword;
+    2: result:=getword;
+    1: result:=getbyte;
+  else
+    result:=0;
+  end;
+{$endif not generic_cpu}
+end;
+
+
 function tentryfile.getaword:{$ifdef generic_cpu}qword{$else}aword{$endif};
 {$ifdef generic_cpu}
 var
@@ -1168,6 +1202,12 @@ begin
 end;
 
 
+procedure tentryfile.putpuint(i : puint);
+begin
+  putdata(i,sizeof(puint));
+end;
+
+
 procedure tentryfile.putaword(i:aword);
 begin
   putdata(i,sizeof(aword));

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion = 192;
+  CurrentPPUVersion = 193;
 
 { unit flags }
   uf_init                = $000001; { unit has initialization section }

+ 2 - 2
compiler/symsym.pas

@@ -2231,7 +2231,7 @@ implementation
            toasm :
              asmname:=ppufile.getpshortstring;
            toaddr :
-             addroffset:=ppufile.getaword;
+             addroffset:=ppufile.getpuint;
          end;
          ppuload_platform(ppufile);
       end;
@@ -2247,7 +2247,7 @@ implementation
            toasm :
              ppufile.putstring(asmname^);
            toaddr :
-             ppufile.putaword(addroffset);
+             ppufile.putpuint(addroffset);
          end;
          writeentry(ppufile,ibabsolutevarsym);
       end;