From 21947f98f6b73477bcab08808ea9a8a37f722e58 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 19 Dec 2024 14:48:13 -0300 Subject: [PATCH] Update codes for static syscalls --- src/lib.rs | 2 +- src/mem/mod.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 98305751..536fb489 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ pub mod x86_64; #[cfg_attr(not(feature = "mangled-names"), no_mangle)] #[linkage = "weak"] pub unsafe extern "C" fn abort() -> ! { - let syscall: extern "C" fn() -> ! = core::mem::transmute(3069975057u64); // murmur32 hash of "abort" + let syscall: extern "C" fn() -> ! = core::mem::transmute(1usize); // 1 is the code for "abort" syscall() } diff --git a/src/mem/mod.rs b/src/mem/mod.rs index c22c3a7e..d4c2de3e 100644 --- a/src/mem/mod.rs +++ b/src/mem/mod.rs @@ -219,25 +219,24 @@ mod syscalls { mod syscalls { pub(crate) fn sol_memcpy_(dest: *mut u8, src: *const u8, n: u64) { let syscall: extern "C" fn(*mut u8, *const u8, u64) = - unsafe { core::mem::transmute(1904002211u64) }; // murmur32 hash of "sol_memcpy_" + unsafe { core::mem::transmute(3usize) }; // 3 is the code for "sol_memcpy_" syscall(dest, src, n) } pub(crate) fn sol_memmove_(dest: *mut u8, src: *const u8, n: u64) { let syscall: extern "C" fn(*mut u8, *const u8, u64) = - unsafe { core::mem::transmute(1128493560u64) }; // murmur32 hash of "sol_memmove_" + unsafe { core::mem::transmute(4usize) }; // 4 is the code for "sol_memmove_" syscall(dest, src, n) } pub(crate) fn sol_memcmp_(dest: *const u8, src: *const u8, n: u64, result: *mut i32) { let syscall: extern "C" fn(*const u8, *const u8, u64, *mut i32) = - unsafe { core::mem::transmute(1608310321u64) }; // murmur32 hash of "sol_memcmp_" + unsafe { core::mem::transmute(6usize) }; // 6 is the code for "sol_memcmp_" syscall(dest, src, n, result) } pub(crate) fn sol_memset_(dest: *mut u8, c: u8, n: u64) { - let syscall: extern "C" fn(*mut u8, u8, u64) = - unsafe { core::mem::transmute(930151202u64) }; // murmur32 hash of "sol_memset_" + let syscall: extern "C" fn(*mut u8, u8, u64) = unsafe { core::mem::transmute(5usize) }; // 5 is the code for "sol_memset_" syscall(dest, c, n) } }