mirror of https://github.com/WebAssembly/wasi-libc
Browse Source
* Implement the critical part of wasi_thread_start in asm It's fragile to set up the critical part of C environment in C. * Specify --target for asm files as well * wasi_thread_start: Move __tls_base initialization to asm as wellsunfishcode/update-emmalloc
YAMAMOTO Takashi
2 years ago
committed by
GitHub
4 changed files with 60 additions and 19 deletions
@ -0,0 +1,31 @@ |
|||||
|
.text |
||||
|
|
||||
|
.export_name wasi_thread_start, wasi_thread_start |
||||
|
|
||||
|
.globaltype __stack_pointer, i32 |
||||
|
.globaltype __tls_base, i32 |
||||
|
.functype __wasi_thread_start_C (i32, i32) -> () |
||||
|
|
||||
|
.hidden wasi_thread_start |
||||
|
.globl wasi_thread_start |
||||
|
.type wasi_thread_start,@function |
||||
|
|
||||
|
wasi_thread_start: |
||||
|
.functype wasi_thread_start (i32, i32) -> () |
||||
|
|
||||
|
# Set up the minimum C environment. |
||||
|
# Note: offsetof(start_arg, stack) == 0 |
||||
|
local.get 1 # start_arg |
||||
|
i32.load 0 # stack |
||||
|
global.set __stack_pointer |
||||
|
|
||||
|
local.get 1 # start_arg |
||||
|
i32.load 4 # tls_base |
||||
|
global.set __tls_base |
||||
|
|
||||
|
# Make the C function do the rest of work. |
||||
|
local.get 0 # tid |
||||
|
local.get 1 # start_arg |
||||
|
call __wasi_thread_start_C |
||||
|
|
||||
|
end_function |
Loading…
Reference in new issue