Skip to content

Commit

Permalink
libia2: WIP stack alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm committed Nov 12, 2024
1 parent f2e0b98 commit 43fdbab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion runtime/libia2/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void *ia2_thread_begin(void *arg) {
: [fn] "r"(fn), [data] "r"(data), [new_sp_addr] "r"(new_sp_addr)
: "rdi");
#elif defined(__aarch64__)
#warning "ia2_thread_begin does not align the stack correctly"
__asm__ volatile(
// Copy stack pointer to x10
"mov x10, sp\n"
Expand All @@ -71,6 +70,12 @@ void *ia2_thread_begin(void *arg) {
"mov sp, x0\n"
// Push the old stack pointer
"str x10, [sp, #-8]!\n"
// Align the stack
//"movn x10, #0x000f\n"
//"and sp, sp, x10, #0\n"
// Prologue (necessary?)
//"str x29, [sp, #-8]!\n"
//"mov x29, sp\n"
// Load argument
"ldr x0, [%[data]]\n"
// Call fn(data)
Expand All @@ -84,6 +89,8 @@ void *ia2_thread_begin(void *arg) {
: [result] "=r"(result)
: [fn] "r"(fn), [data] "r"(&data), [new_sp_addr] "r"(new_sp_addr)
: "x0", "x10");
#else
#error "unknown architecture"
#endif
/* clang-format on */

Expand Down

0 comments on commit 43fdbab

Please sign in to comment.