Browse Source

+ plt for export jmps

git-svn-id: trunk@1579 -
florian 20 years ago
parent
commit
a21b79d316
1 changed files with 22 additions and 4 deletions
  1. 22 4
      compiler/systems/t_linux.pas

+ 22 - 4
compiler/systems/t_linux.pas

@@ -64,9 +64,10 @@ implementation
     cutils,cclasses,
     cutils,cclasses,
     verbose,systems,globtype,globals,
     verbose,systems,globtype,globals,
     symconst,script,
     symconst,script,
-    fmodule,dos
-    ,aasmbase,aasmtai,aasmcpu,cpubase,cgobj
-    ,i_linux
+    fmodule,dos,
+    aasmbase,aasmtai,aasmcpu,cpubase,
+    cgobj,cgutils,
+    i_linux
     ;
     ;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -156,6 +157,8 @@ end;
 procedure texportliblinux.generatelib;
 procedure texportliblinux.generatelib;
 var
 var
   hp2 : texported_item;
   hp2 : texported_item;
+  sym : tasmsymbol;
+  r : treference;
 begin
 begin
   new_section(asmlist[al_procedures],sec_code,'',0);
   new_section(asmlist[al_procedures],sec_code,'',0);
   hp2:=texported_item(current_module._exports.first);
   hp2:=texported_item(current_module._exports.first);
@@ -171,7 +174,22 @@ begin
            { place jump in al_procedures }
            { place jump in al_procedures }
            asmlist[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
            asmlist[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
            asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
            asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
-           cg.a_jmp_name(asmlist[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
+           if (cs_create_pic in aktmoduleswitches) and
+             { other targets need to be checked how it works }
+             (target_info.system in [system_x86_64_linux]) then
+             begin
+{$ifdef x86_64}
+               sym:=objectlibrary.newasmsymbol(s,AB_EXTERNAL,AT_FUNCTION);
+               reference_reset_symbol(r,sym,0);
+               if cs_create_pic in aktmoduleswitches then
+                 r.refaddr:=addr_pic
+               else
+                 r.refaddr:=addr_full;
+               asmlist[al_procedures].concat(taicpu.op_ref(A_JMP,S_NO,r));
+{$endif x86_64}
+             end
+           else
+             cg.a_jmp_name(asmlist[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
            asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
            asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
          end;
          end;
       end
       end