35 lines
1.3 KiB
ArmAsm
35 lines
1.3 KiB
ArmAsm
/*
|
|
* vlibc — x86_64 thread-pointer installer (todo 44).
|
|
*
|
|
* __set_thread_area(tp): install tp as the calling thread's FS base via
|
|
* arch_prctl(ARCH_SET_FS). After this, %fs-relative TLS offsets resolve
|
|
* against tp exactly as the linker baked them (see src/start/tcb.h for the
|
|
* placement contract), and __builtin_thread_pointer() / %fs:0 returns tp.
|
|
*
|
|
* Must be executed IN the thread whose FS base is being set: arch_prctl
|
|
* operates on the current task, so pthread_create (#45) calls this from the
|
|
* new thread's entry point, never from the parent.
|
|
*
|
|
* Return convention: the raw syscall result is left in %eax — 0 on success,
|
|
* a negative errno on failure. No errno write happens here; the caller maps
|
|
* the result however its context needs (this mirrors musl's
|
|
* src/thread/x86_64/__set_thread_area.s, which also returns raw).
|
|
*
|
|
* arch_prctl codes (kernel UAPI asm/prctl.h): ARCH_SET_FS 0x1002,
|
|
* SYS_arch_prctl 158. Kept as literals because there is no internal header
|
|
* for them yet; src/start/tls.c defines the same values locally.
|
|
*/
|
|
|
|
.text
|
|
.global __set_thread_area
|
|
.hidden __set_thread_area
|
|
.type __set_thread_area,@function
|
|
__set_thread_area:
|
|
mov %rdi,%rsi
|
|
movl $0x1002,%edi
|
|
movl $158,%eax
|
|
syscall
|
|
ret
|
|
.size __set_thread_area,.-__set_thread_area
|
|
.section .note.GNU-stack,"",@progbits
|