mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 04:48:07 +02:00
* Use GOT-relative constants for i386 PIC jump tables, they don't need runtime relocations. Now almost ABI-compliant on Linux/BSD (Darwin targets unchanged). Also clean up i8086-specific stuff: using tai_const.create_type_sym(aitconst_ptr,...) generates near pointers on i8086, which is the desired goal.
git-svn-id: trunk@26942 -
This commit is contained in:
parent
d613ab8578
commit
5e8f8f4755
@ -73,6 +73,8 @@ implementation
|
||||
href : treference;
|
||||
jtlist: tasmlist;
|
||||
opcgsize: tcgsize;
|
||||
jumpreg: tregister;
|
||||
labeltyp: taiconst_type;
|
||||
|
||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||
var
|
||||
@ -84,21 +86,13 @@ implementation
|
||||
i:=last.svalue+1;
|
||||
while i<=t^._low.svalue-1 do
|
||||
begin
|
||||
{$ifdef i8086}
|
||||
list.concat(Tai_const.Create_sym_near(elselabel));
|
||||
{$else i8086}
|
||||
list.concat(Tai_const.Create_sym(elselabel));
|
||||
{$endif i8086}
|
||||
list.concat(Tai_const.Create_type_sym(labeltyp,elselabel));
|
||||
inc(i);
|
||||
end;
|
||||
i:=t^._low.svalue;
|
||||
while i<=t^._high.svalue do
|
||||
begin
|
||||
{$ifdef i8086}
|
||||
list.concat(Tai_const.Create_sym_near(blocklabel(t^.blockid)));
|
||||
{$else i8086}
|
||||
list.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
{$endif i8086}
|
||||
list.concat(Tai_const.Create_type_sym(labeltyp,blocklabel(t^.blockid)));
|
||||
inc(i);
|
||||
end;
|
||||
last:=t^._high;
|
||||
@ -108,6 +102,8 @@ implementation
|
||||
|
||||
begin
|
||||
last:=min_;
|
||||
{ This generates near pointers on i8086 }
|
||||
labeltyp:=aitconst_ptr;
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
@ -130,7 +126,18 @@ implementation
|
||||
{$else i8086}
|
||||
href.scalefactor:=sizeof(aint);
|
||||
{$endif i8086}
|
||||
emit_ref(A_JMP,S_NO,href);
|
||||
|
||||
if (not (target_info.system in [system_i386_darwin,system_i386_iphonesim])) and
|
||||
(cs_create_pic in current_settings.moduleswitches) then
|
||||
begin
|
||||
labeltyp:=aitconst_gotoff_symbol;
|
||||
jumpreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_ADDR);
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,jumpreg);
|
||||
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_ADDR,current_procinfo.got,jumpreg);
|
||||
emit_reg(A_JMP,S_NO,jumpreg);
|
||||
end
|
||||
else
|
||||
emit_ref(A_JMP,S_NO,href);
|
||||
{ generate jump table }
|
||||
if (target_info.system in [system_i386_darwin,system_i386_iphonesim]) then
|
||||
jtlist:=current_asmdata.asmlists[al_const]
|
||||
|
Loading…
Reference in New Issue
Block a user