فهرست منبع

+ changed absolute offset variable to aword to avoid range check errors when using addresses > $7fffffff

git-svn-id: trunk@12585 -
florian 16 سال پیش
والد
کامیت
6e700b38a4
2فایلهای تغییر یافته به همراه85 افزوده شده و 4 حذف شده
  1. 82 1
      compiler/ppu.pas
  2. 3 3
      compiler/symsym.pas

+ 82 - 1
compiler/ppu.pas

@@ -242,9 +242,12 @@ type
     procedure getdata(var b;len:integer);
     procedure getdata(var b;len:integer);
     function  getbyte:byte;
     function  getbyte:byte;
     function  getword:word;
     function  getword:word;
+    function  getdword:dword;
     function  getlongint:longint;
     function  getlongint:longint;
     function getint64:int64;
     function getint64:int64;
+    function  getqword:qword;
     function getaint:aint;
     function getaint:aint;
+    function getaword:aword;
     function  getreal:ppureal;
     function  getreal:ppureal;
     function  getstring:string;
     function  getstring:string;
     procedure getnormalset(var b);
     procedure getnormalset(var b);
@@ -259,9 +262,12 @@ type
     procedure putdata(const b;len:integer);
     procedure putdata(const b;len:integer);
     procedure putbyte(b:byte);
     procedure putbyte(b:byte);
     procedure putword(w:word);
     procedure putword(w:word);
+    procedure putdword(w:dword);
     procedure putlongint(l:longint);
     procedure putlongint(l:longint);
     procedure putint64(i:int64);
     procedure putint64(i:int64);
+    procedure putqword(q:qword);
     procedure putaint(i:aint);
     procedure putaint(i:aint);
+    procedure putaword(i:aword);
     procedure putreal(d:ppureal);
     procedure putreal(d:ppureal);
     procedure putstring(const s:string);
     procedure putstring(const s:string);
     procedure putnormalset(const b);
     procedure putnormalset(const b);
@@ -614,7 +620,7 @@ begin
   if entryidx+4>entry.size then
   if entryidx+4>entry.size then
    begin
    begin
      error:=true;
      error:=true;
-     getlongint:=0;
+     result:=0;
      exit;
      exit;
    end;
    end;
 {$ifdef FPC_UNALIGNED_FIXED}
 {$ifdef FPC_UNALIGNED_FIXED}
@@ -632,6 +638,29 @@ begin
 end;
 end;
 
 
 
 
+function tppufile.getdword:dword;
+begin
+  if entryidx+4>entry.size then
+   begin
+     error:=true;
+     result:=0;
+     exit;
+   end;
+{$ifdef FPC_UNALIGNED_FIXED}
+  if bufsize-bufidx>=sizeof(dword) then
+    begin
+      result:=Unaligned(plongint(@buf[bufidx])^);
+      inc(bufidx,sizeof(longint));
+    end
+  else
+{$endif FPC_UNALIGNED_FIXED}
+    readdata(result,sizeof(dword));
+  if change_endian then
+   result:=swapendian(result);
+  inc(entryidx,4);
+end;
+
+
 function tppufile.getint64:int64;
 function tppufile.getint64:int64;
 begin
 begin
   if entryidx+8>entry.size then
   if entryidx+8>entry.size then
@@ -655,6 +684,29 @@ begin
 end;
 end;
 
 
 
 
+function tppufile.getqword:qword;
+begin
+  if entryidx+8>entry.size then
+   begin
+     error:=true;
+     result:=0;
+     exit;
+   end;
+{$ifdef FPC_UNALIGNED_FIXED}
+  if bufsize-bufidx>=sizeof(qword) then
+    begin
+      result:=Unaligned(pqword(@buf[bufidx])^);
+      inc(bufidx,sizeof(qword));
+    end
+  else
+{$endif FPC_UNALIGNED_FIXED}
+    readdata(result,sizeof(qword));
+  if change_endian then
+   result:=swapendian(result);
+  inc(entryidx,8);
+end;
+
+
 function tppufile.getaint:aint;
 function tppufile.getaint:aint;
 begin
 begin
 {$ifdef cpu64bitalu}
 {$ifdef cpu64bitalu}
@@ -665,6 +717,16 @@ begin
 end;
 end;
 
 
 
 
+function tppufile.getaword:aword;
+begin
+{$ifdef cpu64bitalu}
+  result:=getqword;
+{$else cpu64bitalu}
+  result:=getdword;
+{$endif cpu64bitalu}
+end;
+
+
 function tppufile.getreal:ppureal;
 function tppufile.getreal:ppureal;
 var
 var
   d : ppureal;
   d : ppureal;
@@ -997,6 +1059,12 @@ begin
 end;
 end;
 
 
 
 
+procedure tppufile.putdword(w:dword);
+begin
+  putdata(w,4);
+end;
+
+
 procedure tppufile.putlongint(l:longint);
 procedure tppufile.putlongint(l:longint);
 begin
 begin
   putdata(l,4);
   putdata(l,4);
@@ -1009,11 +1077,24 @@ begin
 end;
 end;
 
 
 
 
+procedure tppufile.putqword(q:qword);
+begin
+  putdata(q,sizeof(qword));
+end;
+
+
 procedure tppufile.putaint(i:aint);
 procedure tppufile.putaint(i:aint);
 begin
 begin
   putdata(i,sizeof(aint));
   putdata(i,sizeof(aint));
 end;
 end;
 
 
+
+procedure tppufile.putaword(i:aword);
+begin
+  putdata(i,sizeof(aword));
+end;
+
+
 procedure tppufile.putreal(d:ppureal);
 procedure tppufile.putreal(d:ppureal);
 var
 var
   hd : double;
   hd : double;

+ 3 - 3
compiler/symsym.pas

@@ -203,7 +203,7 @@ interface
          absseg  : boolean;
          absseg  : boolean;
 {$endif i386}
 {$endif i386}
          asmname : pshortstring;
          asmname : pshortstring;
-         addroffset : aint;
+         addroffset : aword;
          ref     : tpropaccesslist;
          ref     : tpropaccesslist;
          constructor create(const n : string;def:tdef);
          constructor create(const n : string;def:tdef);
          constructor create_ref(const n : string;def:tdef;_ref:tpropaccesslist);
          constructor create_ref(const n : string;def:tdef;_ref:tpropaccesslist);
@@ -1375,7 +1375,7 @@ implementation
              asmname:=stringdup(ppufile.getstring);
              asmname:=stringdup(ppufile.getstring);
            toaddr :
            toaddr :
              begin
              begin
-               addroffset:=ppufile.getaint;
+               addroffset:=ppufile.getaword;
 {$ifdef i386}
 {$ifdef i386}
                absseg:=boolean(ppufile.getbyte);
                absseg:=boolean(ppufile.getbyte);
 {$endif i386}
 {$endif i386}
@@ -1395,7 +1395,7 @@ implementation
              ppufile.putstring(asmname^);
              ppufile.putstring(asmname^);
            toaddr :
            toaddr :
              begin
              begin
-               ppufile.putaint(addroffset);
+               ppufile.putaword(addroffset);
 {$ifdef i386}
 {$ifdef i386}
                ppufile.putbyte(byte(absseg));
                ppufile.putbyte(byte(absseg));
 {$endif i386}
 {$endif i386}