summaryrefslogtreecommitdiff
path: root/rt/start-netbsd.s
diff options
context:
space:
mode:
Diffstat (limited to 'rt/start-netbsd.s')
-rw-r--r--rt/start-netbsd.s15
1 files changed, 15 insertions, 0 deletions
diff --git a/rt/start-netbsd.s b/rt/start-netbsd.s
index dd3213e..3a6cfc7 100644
--- a/rt/start-netbsd.s
+++ b/rt/start-netbsd.s
@@ -12,6 +12,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.
@@ -19,6 +23,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
@@ -44,6 +49,16 @@ _start:
pushq %rcx
call cvt
+ /* set up the intial tls region for the main thread */
+ subq $0x10,%rsp
+ movq $165,%rax /* sysarch */
+ movq $15,%rdi /* X8664setfsbase */
+ leaq thread$__tls(%rip),%rsi
+ movq %rsi,(%rsp)
+ movq %rsp,%rsi
+ syscall
+ addq $0x10,%rsp
+
xorq %rbp,%rbp
/* call pre-main initializers */
call __init__