Browse Source

* Proper fix for SPARC cycling with -dCHECK_PIC, pi_needs_got additionally must be set in following cases:
1) tguidconstnode.pass_1 (location is LOC_CREFERENCE)
2) tonnode.pass_1 (generic secondpass references VMT of exception class)
3) Conversion from unsigned to floating-point involves 'magic constant' as GOT-relative data object.
4) Case jumptable address is loaded relative to GOT.

(1) and (2) also provide more accurate setting of pi_needs_got for all targets.

git-svn-id: trunk@23188 -

sergei 12 years ago
parent
commit
c766c50907
4 changed files with 27 additions and 1 deletions
  1. 3 0
      compiler/ncon.pas
  2. 5 0
      compiler/nflw.pas
  3. 6 1
      compiler/sparc/ncpucnv.pas
  4. 13 0
      compiler/sparc/ncpuset.pas

+ 3 - 0
compiler/ncon.pas

@@ -1313,6 +1313,9 @@ implementation
       begin
          result:=nil;
          expectloc:=LOC_CREFERENCE;
+        if (cs_create_pic in current_settings.moduleswitches) and
+          (tf_pic_uses_got in target_info.flags) then
+          include(current_procinfo.flags,pi_needs_got);
       end;
 
     function tguidconstnode.docompare(p: tnode): boolean;

+ 5 - 0
compiler/nflw.pas

@@ -2136,6 +2136,11 @@ implementation
       begin
          result:=nil;
          include(current_procinfo.flags,pi_do_call);
+         { Loads exception class VMT, therefore may need GOT
+           (generic code only; descendants may need to avoid this check) }
+         if (cs_create_pic in current_settings.moduleswitches) and
+           (tf_pic_uses_got in target_info.flags) then
+           include(current_procinfo.flags,pi_needs_got);
          expectloc:=LOC_VOID;
          if assigned(left) then
            firstpass(left);

+ 6 - 1
compiler/sparc/ncpucnv.pas

@@ -87,7 +87,12 @@ implementation
             if is_signed(left.resultdef) then
               inserttypeconv(left,s32inttype)
             else
-              inserttypeconv(left,u32inttype);
+              begin
+                inserttypeconv(left,u32inttype);
+                if (cs_create_pic in current_settings.moduleswitches) and
+                  (tf_pic_uses_got in target_info.flags) then
+                  include(current_procinfo.flags,pi_needs_got);
+              end;
             firstpass(left);
           end;
         result := nil;

+ 13 - 0
compiler/sparc/ncpuset.pas

@@ -27,6 +27,7 @@ unit ncpuset;
 
     uses
        globtype,
+       node,
        nset,
        ncgset;
 
@@ -36,6 +37,8 @@ unit ncpuset;
            procedure optimizevalues(var max_linear_list:aint;var max_dist:aword);override;
            function has_jumptable : boolean;override;
            procedure genjumptable(hp : pcaselabel;min_,max_ : aint);override;
+         public
+           function pass_1:tnode;override;
        end;
 
 
@@ -62,6 +65,16 @@ unit ncpuset;
       end;
 
 
+    function tcpucasenode.pass_1:tnode;
+      begin
+        result:=inherited pass_1;
+        { TODO: ABI-compliant position-independent case code does not involve GOT }
+        if (cs_create_pic in current_settings.moduleswitches) and
+          (tf_pic_uses_got in target_info.flags) then
+          include(current_procinfo.flags,pi_needs_got);
+      end;
+
+
     procedure tcpucasenode.genjumptable(hp : pcaselabel;min_,max_ : aint);
       var
         table : tasmlabel;