Browse Source

* if the Linux target is compiled with FPC_USE_LIBC the initialization of TLS is not required (according to one comment by Florian), so disable all related code in that case (as for example the syscall numbers are not available then)

git-svn-id: trunk@48120 -
svenbarth 4 years ago
parent
commit
359bb64aed
4 changed files with 24 additions and 4 deletions
  1. 4 2
      rtl/linux/i386/si_prc.inc
  2. 2 0
      rtl/linux/si_impl.inc
  3. 10 0
      rtl/linux/system.pp
  4. 8 2
      rtl/linux/x86_64/si_prc.inc

+ 4 - 2
rtl/linux/i386/si_prc.inc

@@ -45,7 +45,9 @@ var
 procedure fpc_geteipasebxlocal; [external name 'fpc_geteipasebx'];
 {$endif}
 
+{$ifndef FPC_USE_LIBC}
 procedure InitTLS; [external name 'FPC_INITTLS'];
+{$endif}
 
 procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
 asm
@@ -95,9 +97,9 @@ asm
   movl    %esp,initialstkptr
 {$endif FPC_PIC}
 
-{$if FPC_FULLVERSION>30200}
+{$if (FPC_FULLVERSION>30200) and not defined(FPC_USE_LIBC)}
   call    InitTLS
-{$endif FPC_FULLVERSION>30200}
+{$endif FPC_FULLVERSION>30200 and not FPC_USE_LIBC}
 
   xorl    %ebp,%ebp
   call    PASCALMAIN

+ 2 - 0
rtl/linux/si_impl.inc

@@ -16,7 +16,9 @@ procedure PascalMain; external name 'PASCALMAIN';
 
 {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
 procedure SysEntry(constref info: TEntryInformation); external name 'FPC_SysEntry';
+{$ifndef FPC_USE_LIBC}
 procedure SysEntry_InitTLS(constref info: TEntryInformation); external name 'FPC_SysEntry_InitTLS';
+{$endif FPC_USE_LIBC}
 
 var
   InitFinalTable : record end; external name 'INITFINAL';

+ 10 - 0
rtl/linux/system.pp

@@ -125,6 +125,9 @@ procedure OsSetupEntryInformation(constref info: TEntryInformation); forward;
                                TLS handling
 *****************************************************************************}
 
+{ TLS initialization is not required if linking against libc }
+{$if not defined(FPC_USE_LIBC)}
+
 {$if defined(CPUARM)}
 {$define INITTLS}
 Function fpset_tls(p : pointer;size : SizeUInt):cint;
@@ -185,6 +188,8 @@ begin
 end;
 {$endif defined(CPUX86_64)}
 
+{$endif not FPC_USE_LIBC}
+
 
 {$ifdef INITTLS}
 { This code initialized the TLS segment for single threaded and static programs.
@@ -323,6 +328,8 @@ begin
   info.PascalMain();
 end;
 
+
+{$ifndef FPC_USE_LIBC}
 procedure SysEntry_InitTLS(constref info: TEntryInformation);[public,alias:'FPC_SysEntry_InitTLS'];
 begin
   SetupEntryInformation(info);
@@ -334,6 +341,7 @@ begin
 {$endif cpui386}
   info.PascalMain();
 end;
+{$endif FPC_USE_LIBC}
 
 {$else}
 var
@@ -361,6 +369,7 @@ begin
 end;
 
 
+{$ifdef FPC_USE_LIBC}
 procedure SysEntry_InitTLS(constref info: TEntryInformation);[public,alias:'FPC_SysEntry_InitTLS'];
 begin
   initialstkptr := info.OS.stkptr;
@@ -375,6 +384,7 @@ begin
 {$endif cpui386}
   info.PascalMain();
 end;
+{$endif FPC_USE_LIBC}
 
 {$endif FPC_BOOTSTRAP_INDIRECT_ENTRY}
 

+ 8 - 2
rtl/linux/x86_64/si_prc.inc

@@ -35,7 +35,9 @@
 
 {$L abitag.o}
 
+{$ifndef FPC_USE_LIBC}
 procedure InitTLS; [external name 'FPC_INITTLS'];
+{$endif}
 
 {******************************************************************************
                           Process start/halt
@@ -73,7 +75,11 @@ procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
     movq    %r10,%rdi
 
     xorq    %rbp, %rbp
+{$ifdef FPC_USE_LIBC}
+    call    SysEntry
+{$else}
     call    SysEntry_InitTLS
+{$endif}
 {$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}
     popq     %rsi                                  { Pop the argument count.  }
     movq     operatingsystem_parameter_argc@GOTPCREL(%rip),%rax
@@ -90,9 +96,9 @@ procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
     movq    initialstkptr@GOTPCREL(%rip),%rax
     movq    %rsp,(%rax)
 
-{$if FPC_FULLVERSION>30200}
+{$if (FPC_FULLVERSION>30200) and not defined(FPC_USE_LIBC)}
     call    InitTLS
-{$endif FPC_FULLVERSION>30200}
+{$endif FPC_FULLVERSION>30200 and not FPC_USE_LIBC}
 
     xorq    %rbp, %rbp
     call    PASCALMAIN