From 59096eb989443ea95ff52e2921e508f4d1b1f8bb Mon Sep 17 00:00:00 2001 From: "Thomas A." Date: Sun, 11 Feb 2024 18:11:40 -0800 Subject: [PATCH] Set Carry Flag If Returned Value Is Between [-1, -4095] Based off of how we handle the carry flag for x86. --- gen/bsdsyscalls/SYS.h | 3 +++ libsyscall/custom/SYS.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gen/bsdsyscalls/SYS.h b/gen/bsdsyscalls/SYS.h index 8494849..47dfcf3 100644 --- a/gen/bsdsyscalls/SYS.h +++ b/gen/bsdsyscalls/SYS.h @@ -476,11 +476,14 @@ pseudo: ;\ */ #ifdef DARLING +// In addition to changing the macro to use __darling_handle_svc instead of the +// syscall (svc) instruction, We are also setting the carry flag as well. #define DO_SYSCALL(num, cerror) \ mov x16, #(num) %%\ PUSH_FRAME %%\ bl __darling_handle_svc %%\ POP_FRAME %%\ + cmn x0, #4095 %%\ b.cc 2f %%\ ARM64_STACK_PROLOG %%\ PUSH_FRAME %%\ diff --git a/libsyscall/custom/SYS.h b/libsyscall/custom/SYS.h index 8494849..47dfcf3 100644 --- a/libsyscall/custom/SYS.h +++ b/libsyscall/custom/SYS.h @@ -476,11 +476,14 @@ pseudo: ;\ */ #ifdef DARLING +// In addition to changing the macro to use __darling_handle_svc instead of the +// syscall (svc) instruction, We are also setting the carry flag as well. #define DO_SYSCALL(num, cerror) \ mov x16, #(num) %%\ PUSH_FRAME %%\ bl __darling_handle_svc %%\ POP_FRAME %%\ + cmn x0, #4095 %%\ b.cc 2f %%\ ARM64_STACK_PROLOG %%\ PUSH_FRAME %%\