Browse Source

* assemble.pas (TInternalAssembler.TreePass0): Avoid range/overflow check error.
(TInternalAssembler.TreePass2): Check that objsymend and objsym are in same section
and avoid range/overflow check error.

git-svn-id: trunk@43028 -

pierre 5 years ago
parent
commit
eb3a470f45
1 changed files with 14 additions and 1 deletions
  1. 14 1
      compiler/assemble.pas

+ 14 - 1
compiler/assemble.pas

@@ -1615,9 +1615,11 @@ Implementation
                                     (objsym.objsection<>ObjData.CurrObjSec) then
                                     (objsym.objsection<>ObjData.CurrObjSec) then
                                    InternalError(200404124);
                                    InternalError(200404124);
                                end
                                end
+{$push} {$R-}{$Q-}
                              else
                              else
                                Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
                                Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
                            end;
                            end;
+{$pop}
                        end;
                        end;
                    end;
                    end;
                  ObjData.alloc(tai_const(hp).size);
                  ObjData.alloc(tai_const(hp).size);
@@ -1768,9 +1770,11 @@ Implementation
                             (objsym.objsection<>ObjData.CurrObjSec) then
                             (objsym.objsection<>ObjData.CurrObjSec) then
                            internalerror(200905042);
                            internalerror(200905042);
                        end
                        end
+{$push} {$R-}{$Q-}
                      else
                      else
                        Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
                        Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
                    end;
                    end;
+{$pop}
                  if (Tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) then
                  if (Tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) then
                    Tai_const(hp).fixsize;
                    Tai_const(hp).fixsize;
                  ObjData.alloc(tai_const(hp).size);
                  ObjData.alloc(tai_const(hp).size);
@@ -1981,8 +1985,17 @@ Implementation
                      objsym:=Objdata.SymbolRef(tai_const(hp).sym);
                      objsym:=Objdata.SymbolRef(tai_const(hp).sym);
                      objsymend:=Objdata.SymbolRef(tai_const(hp).endsym);
                      objsymend:=Objdata.SymbolRef(tai_const(hp).endsym);
                      relative_reloc:=(objsym.objsection<>objsymend.objsection);
                      relative_reloc:=(objsym.objsection<>objsymend.objsection);
-                     Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
+                     if objsymend.objsection<>objsym.objsection then
+                       begin
+                         if (Tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) or
+                            (objsym.objsection<>ObjData.CurrObjSec) then
+                           internalerror(2019010301);
+                       end
+                     else
+{$push} {$R-}{$Q-}
+                       Tai_const(hp).value:=objsymend.address-objsym.address+Tai_const(hp).symofs;
                    end;
                    end;
+{$pop}
                  case tai_const(hp).consttype of
                  case tai_const(hp).consttype of
                    aitconst_64bit,
                    aitconst_64bit,
                    aitconst_32bit,
                    aitconst_32bit,