Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOL] Update codes for static syscalls #24

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
9 changes: 4 additions & 5 deletions src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading