* 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 -
This commit is contained in:
sergei 2012-12-18 17:56:56 +00:00
parent 658968ef44
commit c766c50907
4 changed files with 27 additions and 1 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;