Skip to content

Commit 3c9a97e

Browse files
committed
aarch64 stack bottom
1 parent f39bb15 commit 3c9a97e

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

thread/thread.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,16 @@ R"(
754754
DEF_ASM_FUNC(_photon_thread_stub)
755755
R"(
756756
mov %rbp, %rbx
757-
mov $0, %rbp
758-
call _asan_start
757+
xor %rbp, %rbp
758+
)"
759+
#ifdef __SANITIZE_ADDRESS__
760+
R"(
761+
call _asan_start
762+
)"
763+
#endif
764+
R"(
759765
mov 0x40(%rbx), %rdi
760-
movq $0, 0x40(%rbx)
766+
movq %rbp, 0x40(%rbx)
761767
call *0x48(%rbx)
762768
mov %rax, 0x48(%rbx)
763769
mov %rbx, %rdi
@@ -820,7 +826,6 @@ R"(
820826

821827
DEF_ASM_FUNC(_photon_thread_stub)
822828
R"(
823-
call _asan_start
824829
mov 0x40(%rbp), %rcx
825830
movq $0, 0x40(%rbp)
826831
call *0x48(%rbp)
@@ -895,13 +900,21 @@ R"(
895900
)"
896901

897902
DEF_ASM_FUNC(_photon_thread_stub)
903+
R"(
904+
mov x28, x29
905+
mov x29, xzr
906+
)"
907+
#ifdef __ADDRESS_SANITIZER__
898908
R"(
899909
bl _asan_start //; asan_start()
900-
ldp x0, x1, [x29, #0x40] //; load arg, start into x0, x1
901-
str xzr, [x29, #0x40] //; set arg as 0
910+
)"
911+
#endif
912+
R"(
913+
ldp x0, x1, [x28, #0x40] //; load arg, start into x0, x1
914+
str xzr, [x28, #0x40] //; set arg as 0
902915
blr x1 //; start(x0)
903-
str x0, [x29, #0x48] //; retval = result
904-
mov x0, x29 //; move th to x0
916+
str x0, [x28, #0x48] //; retval = result
917+
mov x0, x28 //; move th to x0
905918
b _photon_thread_die //; _photon_thread_die(th)
906919
)"
907920
);

0 commit comments

Comments
 (0)