소스 검색

* renamed tls model switches and symbols to match gcc

git-svn-id: trunk@43122 -
florian 5 년 전
부모
커밋
03f7ef4c63
7개의 변경된 파일31개의 추가작업 그리고 19개의 파일을 삭제
  1. 1 1
      Makefile
  2. 1 1
      Makefile.fpc
  3. 8 3
      compiler/arm/cpuelf.pas
  4. 10 3
      compiler/globtype.pas
  5. 1 1
      compiler/i386/cpupi.pas
  6. 6 6
      compiler/options.pas
  7. 4 4
      compiler/x86/nx86ld.pas

+ 1 - 1
Makefile

@@ -472,7 +472,7 @@ OPTNEW+=$(OPT)
 endif
 endif
 ifneq ($(findstring $(OS_TARGET),linux),)
 ifneq ($(findstring $(OS_TARGET),linux),)
 ifneq ($(findstring $(CPU_TARGET),i386),)
 ifneq ($(findstring $(CPU_TARGET),i386),)
-override OPTNEW+=-CVgeneral
+override OPTNEW+=-CVgeneral-dynamic
 endif
 endif
 endif
 endif
 CLEANOPTS=FPC=$(PPNEW)
 CLEANOPTS=FPC=$(PPNEW)

+ 1 - 1
Makefile.fpc

@@ -202,7 +202,7 @@ endif
 # the general threading model when compiling the final versions of rtl and packages
 # the general threading model when compiling the final versions of rtl and packages
 ifneq ($(findstring $(OS_TARGET),linux),)
 ifneq ($(findstring $(OS_TARGET),linux),)
 ifneq ($(findstring $(CPU_TARGET),i386),)
 ifneq ($(findstring $(CPU_TARGET),i386),)
-override OPTNEW+=-CVgeneral
+override OPTNEW+=-CVgeneral-dynamic
 endif
 endif
 endif
 endif
 
 

+ 8 - 3
compiler/arm/cpuelf.pas

@@ -28,7 +28,7 @@ interface
 implementation
 implementation
 
 
   uses
   uses
-    globtype,cutils,cclasses,
+    globtype,globals,cutils,cclasses,
     verbose, elfbase,
     verbose, elfbase,
     systems,aasmbase,ogbase,ogelf,assemble;
     systems,aasmbase,ogbase,ogelf,assemble;
 
 
@@ -335,9 +335,14 @@ implementation
           result:=R_ARM_THM_CALL;
           result:=R_ARM_THM_CALL;
         RELOC_GOT32:
         RELOC_GOT32:
           result:=R_ARM_GOT_BREL;
           result:=R_ARM_GOT_BREL;
+        RELOC_TPOFF:
+          if current_settings.tlsmodel=tlsm_initial_exec then
+            result:=R_ARM_TLS_IE32
+          else if current_settings.tlsmodel=tlsm_local_exec then
+            result:=R_ARM_TLS_LE32
+          else
+            Internalerror(2019092901);
       else
       else
-        result:=0;
-        writeln(objrel.typ);
         InternalError(2012110602);
         InternalError(2012110602);
       end;
       end;
     end;
     end;

+ 10 - 3
compiler/globtype.pas

@@ -744,15 +744,22 @@ interface
          { subroutine uses threadvars }
          { subroutine uses threadvars }
          pi_uses_threadvar,
          pi_uses_threadvar,
          { set if the procedure has generated data which shall go in an except table }
          { set if the procedure has generated data which shall go in an except table }
-         pi_has_except_table_data
+         pi_has_except_table_data,
+         { subroutine needs to load and maintain a tls register }
+         pi_needs_tls
        );
        );
        tprocinfoflags=set of tprocinfoflag;
        tprocinfoflags=set of tprocinfoflag;
 
 
        ttlsmodel = (tlsm_none,
        ttlsmodel = (tlsm_none,
          { elf tls model: works for all kind of code and thread vars }
          { elf tls model: works for all kind of code and thread vars }
-         tlsm_general,
+         tlsm_general_dynamic,
+         { elf tls model: works only if the thread vars are declared and used in the same module,
+           regardless when the module is loaded }
+         tlsm_local_dynamic,
+         { elf tls model: works only if the thread vars are declared and used in modules and executables loaded at startup }
+         tlsm_initial_exec,
          { elf tls model: works only if the thread vars are declared and used in the same executable }
          { elf tls model: works only if the thread vars are declared and used in the same executable }
-         tlsm_local
+         tlsm_local_exec
        );
        );
 
 
     type
     type

+ 1 - 1
compiler/i386/cpupi.pas

@@ -98,7 +98,7 @@ unit cpupi;
 
 
     procedure tcpuprocinfo.allocate_got_register(list: tasmlist);
     procedure tcpuprocinfo.allocate_got_register(list: tasmlist);
       begin
       begin
-        if (pi_uses_threadvar in flags) and (tf_section_threadvars in target_info.flags) and (current_settings.tlsmodel in [tlsm_general]) then
+        if (pi_uses_threadvar in flags) and (tf_section_threadvars in target_info.flags) and (current_settings.tlsmodel in [tlsm_general_dynamic]) then
           begin
           begin
             { FIXME: It is better to use an imaginary register for GOT and
             { FIXME: It is better to use an imaginary register for GOT and
               if EBX is needed for some reason just allocate EBX and
               if EBX is needed for some reason just allocate EBX and

+ 6 - 6
compiler/options.pas

@@ -1485,10 +1485,10 @@ begin
                     'V':
                     'V':
                       begin
                       begin
                         s:=upper(copy(more,j+1,length(more)-j));
                         s:=upper(copy(more,j+1,length(more)-j));
-                        if s='GENERAL' then
-                          init_settings.tlsmodel:=tlsm_general
-                        else if s='LOCAL' then
-                          init_settings.tlsmodel:=tlsm_local
+                        if s='GENERAL-DYNAMIC' then
+                          init_settings.tlsmodel:=tlsm_general_dynamic
+                        else if s='LOCAL-EXEC' then
+                          init_settings.tlsmodel:=tlsm_local_exec
                         else
                         else
                           IllegalPara(opt);
                           IllegalPara(opt);
                         break;
                         break;
@@ -4155,9 +4155,9 @@ begin
   if (tf_section_threadvars in target_info.flags) and (init_settings.tlsmodel=tlsm_none) then
   if (tf_section_threadvars in target_info.flags) and (init_settings.tlsmodel=tlsm_none) then
     begin
     begin
       if cs_create_pic in init_settings.moduleswitches then
       if cs_create_pic in init_settings.moduleswitches then
-        init_settings.tlsmodel:=tlsm_general
+        init_settings.tlsmodel:=tlsm_general_dynamic
       else
       else
-        init_settings.tlsmodel:=tlsm_local;
+        init_settings.tlsmodel:=tlsm_local_exec;
     end;
     end;
 
 
   { set Mac OS X version default macros if not specified explicitly }
   { set Mac OS X version default macros if not specified explicitly }

+ 4 - 4
compiler/x86/nx86ld.pas

@@ -93,12 +93,12 @@ implementation
               system_i386_linux,system_i386_android:
               system_i386_linux,system_i386_android:
                 begin
                 begin
                   case current_settings.tlsmodel of
                   case current_settings.tlsmodel of
-                    tlsm_local:
+                    tlsm_local_exec:
                       begin
                       begin
                         location.reference.segment:=NR_GS;
                         location.reference.segment:=NR_GS;
                         location.reference.refaddr:=addr_ntpoff;
                         location.reference.refaddr:=addr_ntpoff;
                       end;
                       end;
-                    tlsm_general:
+                    tlsm_general_dynamic:
                       begin
                       begin
                         include(current_procinfo.flags,pi_needs_got);
                         include(current_procinfo.flags,pi_needs_got);
                         reference_reset(href,0,[]);
                         reference_reset(href,0,[]);
@@ -127,12 +127,12 @@ implementation
               system_x86_64_linux:
               system_x86_64_linux:
                 begin
                 begin
                   case current_settings.tlsmodel of
                   case current_settings.tlsmodel of
-                    tlsm_local:
+                    tlsm_local_exec:
                       begin
                       begin
                         location.reference.segment:=NR_FS;
                         location.reference.segment:=NR_FS;
                         location.reference.refaddr:=addr_tpoff;
                         location.reference.refaddr:=addr_tpoff;
                       end;
                       end;
-                    tlsm_general:
+                    tlsm_general_dynamic:
                       begin
                       begin
                         current_asmdata.CurrAsmList.concat(tai_const.Create_8bit($66));
                         current_asmdata.CurrAsmList.concat(tai_const.Create_8bit($66));
                         reference_reset(href,0,[]);
                         reference_reset(href,0,[]);