2023-02-02 23:24:12 +02:00
|
|
|
# uint64_t read_rip()
|
|
|
|
.global read_rip
|
|
|
|
read_rip:
|
|
|
|
popq %rax
|
|
|
|
jmp *%rax
|
|
|
|
|
|
|
|
exit_thread_trampoline:
|
|
|
|
movq 8(%rsp), %rdi
|
|
|
|
ret
|
|
|
|
|
2023-03-09 15:25:39 +02:00
|
|
|
# void start_thread(uint64_t rsp, uint64_t rip)
|
2023-02-02 23:24:12 +02:00
|
|
|
.global start_thread
|
|
|
|
start_thread:
|
2023-03-09 15:25:39 +02:00
|
|
|
movq %rdi, %rsp
|
|
|
|
popq %rdi
|
2023-02-19 17:53:29 +02:00
|
|
|
movq $0, %rbp
|
2023-04-08 00:31:57 +03:00
|
|
|
movq $0, (%rsp)
|
2023-02-02 23:24:12 +02:00
|
|
|
pushq $exit_thread_trampoline
|
|
|
|
sti
|
2023-03-09 15:25:39 +02:00
|
|
|
jmp *%rsi
|
2023-02-02 23:24:12 +02:00
|
|
|
|
2023-02-19 17:53:29 +02:00
|
|
|
# void continue_thread(uint64_t rsp, uint64_t rip)
|
2023-02-02 23:24:12 +02:00
|
|
|
.global continue_thread
|
|
|
|
continue_thread:
|
|
|
|
movq %rdi, %rsp
|
|
|
|
movq $0, %rax
|
2023-02-19 17:53:29 +02:00
|
|
|
jmp *%rsi
|