Explorar el Código

* we have to use __tls_get_addr from the dyn. linker lib else tls on programs with pure pascal dyn. libraries fail

git-svn-id: trunk@43069 -
florian hace 5 años
padre
commit
f6667a5143
Se han modificado 2 ficheros con 22 adiciones y 20 borrados
  1. 22 15
      compiler/systems/t_linux.pas
  2. 0 5
      rtl/linux/x86_64/si_prc.inc

+ 22 - 15
compiler/systems/t_linux.pas

@@ -458,7 +458,7 @@ Var
   s,s1,s2      : TCmdStr;
   found1,
   found2       : boolean;
-  linksToSharedLibFiles : boolean;
+  linksToSharedLibFiles, libraryadded: boolean;
 begin
   result:=False;
 { set special options for some targets }
@@ -587,22 +587,29 @@ begin
             (TCmdStrListItem(SharedLibFiles.First).Str<>'c') or
             reorder then
            begin
+             libraryadded:=false;
              Add('INPUT(');
              While not SharedLibFiles.Empty do
-              begin
-                S:=SharedLibFiles.GetFirst;
-                if (s<>'c') or reorder then
-                 begin
-                   i:=Pos(target_info.sharedlibext,S);
-                   if i>0 then
-                    Delete(S,i,255);
-                   Add('-l'+s);
-                 end
-                else
-                 begin
-                  linklibc:=true;
-              end;
-              end;
+               begin
+                 S:=SharedLibFiles.GetFirst;
+                 if (s<>'c') or reorder then
+                  begin
+                    i:=Pos(target_info.sharedlibext,S);
+                    if i>0 then
+                     Delete(S,i,255);
+                    Add('-l'+s);
+                    libraryadded:=true;
+                  end
+                 else
+                   linklibc:=true;
+               end;
+             { link explicitly against the dyn. linker in case we are using section threadvars and
+               if we link against any other library. We need __tls_get_addr from the dyn. linker in this case.
+               This does not hurt as in case we use a dyn. library we depend on the dyn. linker anyways.
+
+               All this does not apply if we link anyways against libc }
+             if libraryadded and not(linklibc) and not(isdll) and (tf_section_threadvars in target_info.flags) then
+               Add('-l:'+ExtractFileName(defdynlinker));
              Add(')');
            end
          else

+ 0 - 5
rtl/linux/x86_64/si_prc.inc

@@ -37,11 +37,6 @@
 
 procedure InitTLS; [external name 'FPC_INITTLS'];
 
-{ so far, I found no case where this is actually called, so it is a dummy so far (FK) }
-function __tls_get_addr(p : pointer) : pointer; public name '__tls_get_addr';
-  begin
-  end;
-
 {******************************************************************************
                           Process start/halt
  ******************************************************************************}