提交 b9d32b50 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

call forkt_setup to allocate tls data

上级 a6061522
...@@ -13,8 +13,6 @@ struct tlsdata { ...@@ -13,8 +13,6 @@ struct tlsdata {
void void
forkt_setup() forkt_setup()
{ {
printf("forkt_setup: pid %d\n", getpid());
tlsdata* t = (tlsdata*) sbrk(sizeof(*t)); tlsdata* t = (tlsdata*) sbrk(sizeof(*t));
setfs((u64) t); setfs((u64) t);
} }
......
...@@ -8,8 +8,9 @@ forkt: ...@@ -8,8 +8,9 @@ forkt:
pushq %r12 pushq %r12
andq $(~0xf), %rdi # new stack ptr amd64 ABI alignment andq $(~0xf), %rdi # new stack ptr amd64 ABI alignment
movq %rdi, %r12 movq %rdi, %r12
movq %rdx, -16(%r12) # arg subq $0x10, %r12
movq %rsi, -8(%r12) # function ptr movq %rdx, 0x00(%r12) # arg
movq %rsi, 0x08(%r12) # function ptr
movq $1, %rdi # flag for sys_fork movq $1, %rdi # flag for sys_fork
movq $SYS_fork, %rax movq $SYS_fork, %rax
...@@ -19,9 +20,11 @@ forkt: ...@@ -19,9 +20,11 @@ forkt:
jne 1f jne 1f
# child # child
movq -8(%r12), %rax
movq -16(%r12), %rdi
movq %r12, %rsp movq %r12, %rsp
movq %rax, %rdi
call forkt_setup
popq %rdi
popq %rax
call *%rax call *%rax
call exit call exit
1: # parent 1: # parent
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论