From db0190b6eca450b3016f4384654c6f039906d7bb Mon Sep 17 00:00:00 2001 From: jschwabe Date: Tue, 20 May 2025 16:10:42 +0200 Subject: [PATCH 1/2] fix: macos syscall 16 byte stack alignment --- nasm/linked_list/ft_linked_list.s | 4 ++++ nasm/strdup/ft_strdup.s | 2 ++ 2 files changed, 6 insertions(+) diff --git a/nasm/linked_list/ft_linked_list.s b/nasm/linked_list/ft_linked_list.s index 893e346..3452d38 100644 --- a/nasm/linked_list/ft_linked_list.s +++ b/nasm/linked_list/ft_linked_list.s @@ -35,7 +35,9 @@ SYM(ft_create_elem): enter 0, 0 push rdi mov rdi, ELEM_SIZE + sub rsp, 8 call SYM_SYSCALL(malloc) + add rsp, 8 test rax, rax jz .error_malloc ; rax has 16 bytes @@ -170,7 +172,9 @@ SYM(ft_list_remove_if): mov rdi, [r12] call [rsp + 8]; free_fct on cur->data mov rdi, r12; setup: free cur (node) + sub rsp, 8 call SYM_SYSCALL(free) + add rsp, 8 test r13, r13 jz .rmfirst_reset_begin .rm_nonfirst_update_prev: diff --git a/nasm/strdup/ft_strdup.s b/nasm/strdup/ft_strdup.s index 2eb6a83..7175cc8 100644 --- a/nasm/strdup/ft_strdup.s +++ b/nasm/strdup/ft_strdup.s @@ -30,7 +30,9 @@ SYM(ft_strdup): inc rax ; call with rax value mov rdi, rax + sub rsp, 8 call SYM_SYSCALL(malloc) + add rsp, 8 test rax, rax jz .error_malloc mov rdi, rax ; provide dest: new allocation From 99bff14d93991eac017e6eefe51b5ab7c9fe2b8d Mon Sep 17 00:00:00 2001 From: jschwabe Date: Tue, 20 May 2025 16:21:13 +0200 Subject: [PATCH 2/2] test: more macos platforms --- .github/workflows/binaries.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 0a9194a..3fd33ce 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -25,7 +25,20 @@ jobs: run: cd nasm && make test_mains - name: linkable binary run: cd nasm && make bin && ./linkable_binary.out - test-macos: + test-macos-xcode_15_2-intel: + + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + - name: add nasm + run: brew install nasm + - name: Run tests + run: cd nasm && make test_mains + # binary segfaults on macos catalina without 16-byte-alignment for syscalls (stack_not_16_byte_aligned_error) + - name: linkable binary + run: cd nasm && make bin && ./linkable_binary.out + test-macos-xcode_16-emulated: runs-on: macos-15 @@ -35,6 +48,6 @@ jobs: run: brew install nasm - name: Run tests run: cd nasm && make test_mains - # binary segfaults on gha macos (arm64) when not specifying macos-15 + # binary segfaults on gha arm64 when not running with macos-14/latest - name: linkable binary run: cd nasm && make bin && ./linkable_binary.out \ No newline at end of file