diff options
Diffstat (limited to 'zap/source/amd64')
-rw-r--r-- | zap/source/amd64/bs/trap.s | 4 | ||||
-rw-r--r-- | zap/source/amd64/sys/syscall.s | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/zap/source/amd64/bs/trap.s b/zap/source/amd64/bs/trap.s index 93138e5..19c52a8 100644 --- a/zap/source/amd64/bs/trap.s +++ b/zap/source/amd64/bs/trap.s @@ -4,7 +4,7 @@ .intel_syntax noprefix -.globl zap_priv_trap +.globl zap_trap -zap_priv_trap: +zap_trap: ud2 diff --git a/zap/source/amd64/sys/syscall.s b/zap/source/amd64/sys/syscall.s new file mode 100644 index 0000000..f6a615a --- /dev/null +++ b/zap/source/amd64/sys/syscall.s @@ -0,0 +1,27 @@ +# Copyright 2022-2023 Gabriel Jensen. +# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>. + +.globl zap_syscall + +zap_syscall: + # System calls on AMD64 use the following registers: + # rax : System call identifier + # rdi : First parameter + # rsi : Second parameter + # rdx : Third parameter + # r10 : Fourth parameter + # r8 : Fifth parameter + # r9 : Sixth parameter + # eax : Return value + # No registers to save. + movq %rdi,%rax # Move the first parameter (the identifier) to rax. + movq %rsi,%rdi # Move parameters into their designated registers. + movq %rdx,%rsi + movq %rcx,%rdx + movq %r8,%r10 # System calls use r10 instead of rcx. + movq %r9,%r8 + movq 0x8(%rsp),%r9 # Extract the sixth argument from the stack. + syscall # Slime incident + # No need to move the return value. + ret |