2024-03-22 14:48:33 +02:00
|
|
|
# uint64_t read_()
|
|
|
|
.global read_ip
|
|
|
|
read_ip:
|
2023-02-02 23:24:12 +02:00
|
|
|
popq %rax
|
|
|
|
jmp *%rax
|
|
|
|
|
|
|
|
exit_thread_trampoline:
|
|
|
|
movq 8(%rsp), %rdi
|
|
|
|
ret
|
|
|
|
|
2024-03-22 14:48:33 +02:00
|
|
|
# void start_thread(uint64_t sp, uint64_t ip)
|
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-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
|
|
|
|
2024-03-22 14:48:33 +02:00
|
|
|
# void continue_thread(uint64_t sp, uint64_t ip)
|
2023-02-02 23:24:12 +02:00
|
|
|
.global continue_thread
|
|
|
|
continue_thread:
|
|
|
|
movq %rdi, %rsp
|
|
|
|
movq $0, %rax
|
2023-04-12 17:51:36 +03:00
|
|
|
jmp *%rsi
|
|
|
|
|
2024-03-22 14:48:33 +02:00
|
|
|
# void thread_userspace_trampoline(uint64_t sp, uint64_t ip, int argc, char** argv, char** envp)
|
2023-05-16 00:27:49 +03:00
|
|
|
.global thread_userspace_trampoline
|
|
|
|
thread_userspace_trampoline:
|
2023-04-12 17:51:36 +03:00
|
|
|
pushq $0x23
|
|
|
|
pushq %rdi
|
|
|
|
pushfq
|
|
|
|
pushq $0x1B
|
|
|
|
pushq %rsi
|
2023-05-16 00:27:49 +03:00
|
|
|
movq %rdx, %rdi
|
|
|
|
movq %rcx, %rsi
|
2023-06-05 20:34:08 +03:00
|
|
|
movq %r8, %rdx
|
2023-04-12 17:51:36 +03:00
|
|
|
iretq
|