diff --git a/configure b/configure index 583efbc..1bd90c5 100755 --- a/configure +++ b/configure @@ -67,9 +67,14 @@ case `uname -m` in machine="riscv" CFLAGS="$CFLAGS -DMLX_RISCV64" ;; +'sw_64') + machine="sw_64" + CFLAGS="$CFLAGS -DMLX_SW_64" + LDFLAGS="$LDFLAGS -llzma" + ;; *) echo "Error: unsupported machine: `uname -m`." - echo "Only x86, x86_64, arm, loongarch, riscv and aarch64 are supported." + echo "Only x86, x86_64, arm, loongarch, riscv, sw_64 and aarch64 are supported." exit 2 ;; esac diff --git a/machines.h b/machines.h index c92da46..97eb696 100644 --- a/machines.h +++ b/machines.h @@ -206,6 +206,35 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address) { return ptrace_get_data(pid, address) == 0x00100073; } +#elif defined(MLX_SW_64) +static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs) +{ + return regs->regs[30]; +} +static inline uintptr_t call_return_value(registers_info_t *regs) +{ + return regs->regs[0]; +} +static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs) +{ + return regs->regs[0]; +} +static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs) +{ + return regs->regs[1]; +} +static inline uintptr_t pc_unwind(pid_t pid, registers_info_t *regs) +{ + return regs->pc; +} +static inline void set_breakpoint(pid_t pid, uintptr_t address, uintptr_t code) +{ + ptrace_set_data(pid, address, 0x00000080); +} +static inline int is_breakpoint(pid_t pid, uintptr_t address) +{ + return ptrace_get_data(pid, address) == 0x00000080; +} #endif #endif diff --git a/ptrace_utils.h b/ptrace_utils.h index a9ef0f4..9a10327 100644 --- a/ptrace_utils.h +++ b/ptrace_utils.h @@ -17,8 +17,65 @@ #include #include #include + +#ifdef MLX_SW_64 +#ifndef __ASSEMBLY__ + +struct pt_regs { + union { + struct user_pt_regs user_regs; + struct { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r16; + unsigned long r17; + unsigned long r18; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; + unsigned long r28; + unsigned long gp; + unsigned long sp; + unsigned long pc; + unsigned long ps; + }; + }; + /* These are saved by HMcode: */ + unsigned long hm_ps; + unsigned long hm_pc; + unsigned long hm_gp; + unsigned long hm_r16; + unsigned long hm_r17; + unsigned long hm_r18; +}; + +#endif +#endif + #ifdef MLX_ARMv7 typedef struct user_regs registers_info_t; + #elif (defined MLX_SW_64) +typedef struct user_pt_regs registers_info_t; #else typedef struct user_regs_struct registers_info_t; #endif