summaryrefslogtreecommitdiff
path: root/rt/start-linux.s
diff options
context:
space:
mode:
Diffstat (limited to 'rt/start-linux.s')
-rw-r--r--rt/start-linux.s11
1 files changed, 11 insertions, 0 deletions
diff --git a/rt/start-linux.s b/rt/start-linux.s
index 742b4a3..a0cbfb6 100644
--- a/rt/start-linux.s
+++ b/rt/start-linux.s
@@ -4,6 +4,10 @@
sys$__cenvp:
.quad 0
+.globl thread$__tls
+thread$__tls:
+ .fill 88 /* sizeof(tlshdr) + (8 * sizeof(void#)) = 24 + 64 */
+
.text
/*
* The entry point for the whole program.
@@ -11,6 +15,7 @@ sys$__cenvp:
* - Sets up all argc entries as slices
* - Converts argc/argv to a slice
* - Stashes a raw envp copy in __cenvp (for syscalls to use)
+ * - Sets up thread local storage for the main thread
* - Calls main()
*/
.globl _start
@@ -36,6 +41,12 @@ _start:
pushq %rcx
call cvt
+ /* set up the intial tls region for the main thread */
+ movq $158,%rax /* arch_prctl */
+ movq $0x1002,%rdi /* Archsetfs */
+ leaq thread$__tls(%rip),%rsi
+ syscall
+
xorq %rbp,%rbp
/* call pre-main initializers */
call __init__