From e17817664eff6c2b72a05fa1b19800c46ae9c939 Mon Sep 17 00:00:00 2001 From: Ziyao Date: Fri, 15 Apr 2022 09:21:13 +0800 Subject: [PATCH] Fix buggy __syscall6() again.The last argument is stored 8(%rsp),not (%rsp) --- src/internal/x86_64/syscall.S | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/internal/x86_64/syscall.S b/src/internal/x86_64/syscall.S index c614c73..0aa67ea 100644 --- a/src/internal/x86_64/syscall.S +++ b/src/internal/x86_64/syscall.S @@ -1,6 +1,7 @@ /* musl-tcc File:/src/internal/x86_64/syscall.S + Date:2022.04.15 Copyright(c) 2022 ziyao. */ @@ -18,34 +19,34 @@ .type __syscall4,@function __syscall4: - movq %rdi, %rax - movq %rsi, %rdi - movq %rdx, %rsi - movq %rcx, %rdx - movq %r8, %r10 + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 syscall retq .type __syscall5,@function __syscall5: - movq %rdi, %rax - movq %rsi, %rdi - movq %rdx, %rsi - movq %rcx, %rdx - movq %r8, %r10 - movq %r9, %r8 + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + movq %r9, %r8 syscall retq .type __syscall6,@function __syscall6: - movq %rdi, %rax - movq %rsi, %rdi - movq %rdx, %rsi - movq %rcx, %rdx - movq %r8, %r10 - movq %r9, %r8 - movq (%rsp), %r9 // The last argument is stored on + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + movq %r9, %r8 + movq 8(%rsp), %r9 // The last argument is stored on // the stack // But do NOT mess up the stack syscall