summaryrefslogtreecommitdiff
path: root/rt/start-openbsd.s
diff options
context:
space:
mode:
Diffstat (limited to 'rt/start-openbsd.s')
-rw-r--r--rt/start-openbsd.s10
1 files changed, 10 insertions, 0 deletions
diff --git a/rt/start-openbsd.s b/rt/start-openbsd.s
index c0e061a..eef7b45 100644
--- a/rt/start-openbsd.s
+++ b/rt/start-openbsd.s
@@ -13,6 +13,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.
@@ -20,6 +24,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
@@ -45,6 +50,11 @@ _start:
pushq %rcx
call cvt
+ /* set up the intial tls region for the main thread */
+ movq $329,%rax /* Sys__set_tcb */
+ leaq thread$__tls(%rip),%rdi
+ syscall
+
xorq %rbp,%rbp
/*
we're done startup, and we kind of want