* 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 -
This commit is contained in:
svenbarth 2021-01-09 15:58:13 +00:00
parent c99a97cc55
commit 359bb64aed
4 changed files with 24 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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