summaryrefslogtreecommitdiff
path: root/rtl/linux
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-01-09 15:58:13 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-01-09 15:58:13 +0000
commitd239ddd22ed94b03b3308f3326f01010ae5b6bd5 (patch)
tree711ccfd88dbea1ef032526c29bf85b03d3a866ae /rtl/linux
parentd053d76c532b1a71b0dc7e5b2b4b5d15c424083a (diff)
downloadfpc-d239ddd22ed94b03b3308f3326f01010ae5b6bd5.tar.gz
* 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: https://svn.freepascal.org/svn/fpc/trunk@48120 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl/linux')
-rw-r--r--rtl/linux/i386/si_prc.inc6
-rw-r--r--rtl/linux/si_impl.inc2
-rw-r--r--rtl/linux/system.pp10
-rw-r--r--rtl/linux/x86_64/si_prc.inc10
4 files changed, 24 insertions, 4 deletions
diff --git a/rtl/linux/i386/si_prc.inc b/rtl/linux/i386/si_prc.inc
index ae0531dd9e..1639445a70 100644
--- a/rtl/linux/i386/si_prc.inc
+++ b/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
diff --git a/rtl/linux/si_impl.inc b/rtl/linux/si_impl.inc
index a727310551..2b19deaf10 100644
--- a/rtl/linux/si_impl.inc
+++ b/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';
diff --git a/rtl/linux/system.pp b/rtl/linux/system.pp
index caa4e116c7..4303c61147 100644
--- a/rtl/linux/system.pp
+++ b/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}
diff --git a/rtl/linux/x86_64/si_prc.inc b/rtl/linux/x86_64/si_prc.inc
index 1864e9d559..71804c1343 100644
--- a/rtl/linux/x86_64/si_prc.inc
+++ b/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