Skip to content
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
15 changes: 4 additions & 11 deletions src/arch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use core::arch::asm;
use linux_raw_sys::elf::Elf_Ehdr;
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[cfg(test)]
use linux_raw_sys::general::__NR_rt_sigreturn;
#[cfg(all(feature = "experimental-relocate", feature = "origin-start"))]
#[cfg(relocation_model = "pic")]
Expand Down Expand Up @@ -275,14 +274,13 @@ pub(super) const TLS_OFFSET: usize = 0;
#[cfg(feature = "thread")]
#[inline]
pub(super) unsafe fn munmap_and_exit_thread(map_addr: *mut c_void, map_len: usize) -> ! {
assert_eq!(__NR_exit, 93); // TODO: obviate this
asm!(
"svc 0",
"mov x0, xzr",
"mov x8, 93", // TODO: use {__NR_exit}
"mov x8, {__NR_exit}",
"svc 0",
"udf #16",
//__NR_exit = const __NR_exit, // TODO: Use this when `asm_const` is stabilized.
__NR_exit = const __NR_exit,
in("x8") __NR_munmap,
in("x0") map_addr,
in("x1") map_len,
Expand All @@ -304,16 +302,11 @@ naked_fn!(
";
pub(super) fn return_from_signal_handler() -> ();

"mov x8, 139", // TODO: use {__NR_rt_sigreturn}
"mov x8, {__NR_rt_sigreturn}",
"svc 0",
"udf #16";
//__NR_rt_sigreturn = const __NR_rt_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_rt_sigreturn = const __NR_rt_sigreturn
);
#[cfg(feature = "take-charge")]
#[test] // TODO: obviate this
fn test_rt_sigreturn() {
assert_eq!(__NR_rt_sigreturn, 139);
}

/// Invoke the appropriate system call to return control from a signal
/// handler that does not use `SA_SIGINFO`. On aarch64, this uses the same
Expand Down
24 changes: 6 additions & 18 deletions src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use linux_raw_sys::elf::Elf_Ehdr;
use linux_raw_sys::general::{__NR_mprotect, PROT_READ};
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[cfg(test)]
use linux_raw_sys::general::{__NR_rt_sigreturn, __NR_sigreturn};
#[cfg(feature = "take-charge")]
#[cfg(feature = "thread")]
Expand Down Expand Up @@ -289,14 +288,13 @@ pub(super) const TLS_OFFSET: usize = 0;
#[cfg(feature = "thread")]
#[inline]
pub(super) unsafe fn munmap_and_exit_thread(map_addr: *mut c_void, map_len: usize) -> ! {
assert_eq!(__NR_exit, 1); // TODO: obviate this
asm!(
"svc 0",
"mov r0, #0",
"mov r7, #1", // TODO: use {__NR_exit}
"mov r7, {__NR_exit}",
"svc 0",
"udf #16",
//__NR_exit = const __NR_exit, // TODO: Use this when `asm_const` is stabilized.
__NR_exit = const __NR_exit,
in("r7") __NR_munmap,
in("r0") map_addr,
in("r1") map_len,
Expand All @@ -318,16 +316,11 @@ naked_fn!(
";
pub(super) fn return_from_signal_handler() -> ();

"mov r7, 173", // TODO: use {__NR_rt_sigreturn}
"mov r7, {__NR_rt_sigreturn}",
"swi 0",
"udf #16";
//__NR_rt_sigreturn = const __NR_rt_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_rt_sigreturn = const __NR_rt_sigreturn
);
#[cfg(feature = "take-charge")]
#[test] // TODO: obviate this
fn test_rt_sigreturn() {
assert_eq!(__NR_rt_sigreturn, 173);
}

#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
Expand All @@ -343,13 +336,8 @@ naked_fn!(
";
pub(super) fn return_from_signal_handler_noinfo() -> ();

"mov r7, 119", // TODO: use {__NR_sigreturn}
"mov r7, {__NR_sigreturn}",
"swi 0",
"udf #16";
//__NR_sigreturn = const __NR_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_sigreturn = const __NR_sigreturn
);
#[cfg(feature = "take-charge")]
#[test] // TODO: obviate this
fn test_sigreturn() {
assert_eq!(__NR_sigreturn, 119);
}
5 changes: 2 additions & 3 deletions src/arch/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,13 @@ pub(super) const TLS_OFFSET: usize = 0x800;
#[cfg(feature = "thread")]
#[inline]
pub(super) unsafe fn munmap_and_exit_thread(map_addr: *mut c_void, map_len: usize) -> ! {
assert_eq!(__NR_exit, 93); // TODO: obviate this
asm!(
"ecall",
"mv a0, zero",
"li a7, 93", // TODO: use {__NR_exit}
"li a7, {__NR_exit}",
"ecall",
"unimp",
//__NR_exit = const __NR_exit, // TODO: Use this when `asm_const` is stabilized.
__NR_exit = const __NR_exit,
in("a7") __NR_munmap,
in("a0") map_addr,
in("a1") map_len,
Expand Down
26 changes: 6 additions & 20 deletions src/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use linux_raw_sys::elf::Elf_Ehdr;
use linux_raw_sys::general::{__NR_mprotect, PROT_READ};
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[cfg(test)]
use linux_raw_sys::general::{__NR_rt_sigreturn, __NR_sigreturn};
#[cfg(feature = "take-charge")]
#[cfg(feature = "thread")]
Expand Down Expand Up @@ -371,16 +370,15 @@ pub(super) const TLS_OFFSET: usize = 0;
#[cfg(feature = "thread")]
#[inline]
pub(super) unsafe fn munmap_and_exit_thread(map_addr: *mut c_void, map_len: usize) -> ! {
assert_eq!(__NR_exit, 1); // TODO: obviate this
asm!(
// Use `int 0x80` instead of vsyscall, since vsyscall would attempt to
// touch the stack after we `munmap` it.
"int 0x80",
"xor ebx, ebx",
"mov eax, 1", // TODO: use {__NR_exit}
"mov eax, {__NR_exit}",
"int 0x80",
"ud2",
//__NR_exit = const __NR_exit, // TODO: Use this when `asm_const` is stabilized.
__NR_exit = const __NR_exit,
in("eax") __NR_munmap,
in("ebx") map_addr,
in("ecx") map_len,
Expand All @@ -402,17 +400,11 @@ naked_fn!(
";
pub(super) fn return_from_signal_handler() -> ();

"mov eax, 173", // TODO: use {__NR_rt_sigreturn}
"mov eax, {__NR_rt_sigreturn}",
"int 0x80",
"ud2";
//__NR_rt_sigreturn = const __NR_rt_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_rt_sigreturn = const __NR_rt_sigreturn
);
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[test] // TODO: obviate this
fn test_rt_sigreturn() {
assert_eq!(__NR_rt_sigreturn, 173);
}

#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
Expand All @@ -429,14 +421,8 @@ naked_fn!(
pub(super) fn return_from_signal_handler_noinfo() -> ();

"pop eax",
"mov eax, 119", // TODO: use {__NR_sigreturn}
"mov eax, {__NR_sigreturn}",
"int 0x80",
"ud2";
//__NR_sigreturn = const __NR_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_sigreturn = const __NR_sigreturn
);
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[test] // TODO: obviate this
fn test_sigreturn() {
assert_eq!(__NR_sigreturn, 119);
}
15 changes: 4 additions & 11 deletions src/arch/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use core::arch::asm;
use linux_raw_sys::elf::Elf_Ehdr;
#[cfg(feature = "take-charge")]
#[cfg(feature = "signal")]
#[cfg(test)]
use linux_raw_sys::general::__NR_rt_sigreturn;
#[cfg(all(feature = "experimental-relocate", feature = "origin-start"))]
#[cfg(relocation_model = "pic")]
Expand Down Expand Up @@ -283,14 +282,13 @@ pub(super) const TLS_OFFSET: usize = 0;
#[cfg(feature = "thread")]
#[inline]
pub(super) unsafe fn munmap_and_exit_thread(map_addr: *mut c_void, map_len: usize) -> ! {
assert_eq!(__NR_exit, 60); // TODO: obviate this
asm!(
"syscall",
"xor edi, edi",
"mov eax, 60", // TODO: use {__NR_exit}
"mov eax, {__NR_exit}",
"syscall",
"ud2",
//__NR_exit = const __NR_exit, // TODO: Use this when `asm_const` is stabilized.
__NR_exit = const __NR_exit,
in("rax") __NR_munmap,
in("rdi") map_addr,
in("rsi") map_len,
Expand All @@ -312,16 +310,11 @@ naked_fn!(
";
pub(super) fn return_from_signal_handler() -> ();

"mov rax, 15", // TODO: use {__NR_rt_sigreturn}
"mov rax, {__NR_rt_sigreturn}",
"syscall",
"ud2";
//__NR_rt_sigreturn = const __NR_rt_sigreturn // TODO: Use this when `asm_const` is stabilized.
__NR_rt_sigreturn = const __NR_rt_sigreturn
);
#[cfg(feature = "take-charge")]
#[test] // TODO: obviate this
fn test_rt_sigreturn() {
assert_eq!(__NR_rt_sigreturn, 15);
}

/// Invoke the appropriate system call to return control from a signal
/// handler that does not use `SA_SIGINFO`. On x86-64, this uses the same
Expand Down
45 changes: 0 additions & 45 deletions tests/abi.rs

This file was deleted.