Merge branch 'fix_arm64' into 'master'
Move setjmp and sigsetjmp together See merge request redox-os/relibc!1141
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
.global sigsetjmp
|
||||||
|
.global __sigsetjmp
|
||||||
|
.type sigsetjmp,@function
|
||||||
|
.type __sigsetjmp,@function
|
||||||
|
sigsetjmp:
|
||||||
|
__sigsetjmp:
|
||||||
|
mov ecx, dword ptr [esp + 8]
|
||||||
|
jecxz 1f
|
||||||
|
|
||||||
|
mov eax, dword ptr [esp + 4]
|
||||||
|
pop [eax + 24]
|
||||||
|
mov dword ptr [eax * 8 + 28], ebx
|
||||||
|
mov ebx, eax
|
||||||
|
|
||||||
|
.hidden ___setjmp
|
||||||
|
call ___setjmp
|
||||||
|
|
||||||
|
push [ebx + 24]
|
||||||
|
mov dword ptr [esp + 4], ebx
|
||||||
|
mov dword ptr [esp + 4], eax
|
||||||
|
mov ebx, dword ptr [ebx * 8 + 28]
|
||||||
|
|
||||||
|
.hidden __sigsetjmp_tail
|
||||||
|
jmp __sigsetjmp_tail
|
||||||
|
|
||||||
|
1: jmp ___setjmp
|
||||||
+8
-8
@@ -4,19 +4,19 @@
|
|||||||
.type __sigsetjmp,@function
|
.type __sigsetjmp,@function
|
||||||
sigsetjmp:
|
sigsetjmp:
|
||||||
__sigsetjmp:
|
__sigsetjmp:
|
||||||
test %esi,%esi
|
test esi, esi
|
||||||
jz 1f
|
jz 1f
|
||||||
|
|
||||||
popq 64(%rdi)
|
pop [rdi + 64]
|
||||||
mov %rbx,72+8(%rdi)
|
mov qword ptr [rdi * 8 + 72], rbx
|
||||||
mov %rdi,%rbx
|
mov rbx, rdi
|
||||||
|
|
||||||
call setjmp
|
call setjmp
|
||||||
|
|
||||||
pushq 64(%rbx)
|
push [rbx + 64]
|
||||||
mov %rbx,%rdi
|
mov rdi, rbx
|
||||||
mov %eax,%esi
|
mov esi, eax
|
||||||
mov 72+8(%rbx),%rbx
|
mov rbx, qword ptr [rbx * 8 + 72]
|
||||||
|
|
||||||
.hidden __sigsetjmp_tail
|
.hidden __sigsetjmp_tail
|
||||||
jmp __sigsetjmp_tail
|
jmp __sigsetjmp_tail
|
||||||
@@ -4,18 +4,14 @@
|
|||||||
|
|
||||||
use core::arch::global_asm;
|
use core::arch::global_asm;
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
use core::ffi::c_int;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
use crate::header::signal::sigsetjmp;
|
|
||||||
|
|
||||||
macro_rules! platform_specific {
|
macro_rules! platform_specific {
|
||||||
($($rust_arch:expr,$c_arch:expr,$ext:expr;)+) => {
|
($($rust_arch:expr,$c_arch:expr,$ext:expr;)+) => {
|
||||||
$(
|
$(
|
||||||
#[cfg(target_arch = $rust_arch)]
|
#[cfg(target_arch = $rust_arch)]
|
||||||
global_asm!(include_str!(concat!("impl/", $c_arch, "/setjmp.", $ext)));
|
global_asm!(include_str!(concat!("impl/", $c_arch, "/setjmp.", $ext)));
|
||||||
#[cfg(target_arch = $rust_arch)]
|
#[cfg(target_arch = $rust_arch)]
|
||||||
|
global_asm!(include_str!(concat!("impl/", $c_arch, "/sigsetjmp.", $ext)));
|
||||||
|
#[cfg(target_arch = $rust_arch)]
|
||||||
global_asm!(include_str!(concat!("impl/", $c_arch, "/longjmp.", $ext)));
|
global_asm!(include_str!(concat!("impl/", $c_arch, "/longjmp.", $ext)));
|
||||||
)+
|
)+
|
||||||
}
|
}
|
||||||
@@ -35,15 +31,3 @@ unsafe extern "C" {
|
|||||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/longjmp.html>.
|
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/longjmp.html>.
|
||||||
pub fn longjmp(jb: *mut u64, ret: i32);
|
pub fn longjmp(jb: *mut u64, ret: i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
#[unsafe(no_mangle)]
|
|
||||||
pub unsafe extern "C" fn __relibc_unused_but_exist_to_avoid_linker_error_on_setjmp(arg: c_int) {
|
|
||||||
// Workaround to https://www.openwall.com/lists/musl/2023/09/07/2
|
|
||||||
// By keeping setjmp close to sigsetjmp in link time
|
|
||||||
let jb: *mut u64 = core::ptr::null_mut();
|
|
||||||
unsafe {
|
|
||||||
setjmp(jb);
|
|
||||||
sigsetjmp(jb, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html>.
|
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html>.
|
||||||
|
|
||||||
use core::{arch::global_asm, mem, ptr};
|
use core::{mem, ptr};
|
||||||
|
|
||||||
use cbitset::BitSet;
|
use cbitset::BitSet;
|
||||||
|
|
||||||
@@ -111,24 +111,6 @@ pub type siginfo_t = siginfo;
|
|||||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html>
|
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html>
|
||||||
pub type stack_t = sigaltstack;
|
pub type stack_t = sigaltstack;
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
global_asm!(include_str!("sigsetjmp/aarch64/sigsetjmp.s"));
|
|
||||||
|
|
||||||
#[cfg(target_arch = "riscv64")]
|
|
||||||
global_asm!(include_str!("sigsetjmp/riscv64/sigsetjmp.s"));
|
|
||||||
|
|
||||||
#[cfg(target_arch = "x86")]
|
|
||||||
global_asm!(
|
|
||||||
include_str!("sigsetjmp/i386/sigsetjmp.s"),
|
|
||||||
options(att_syntax)
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
global_asm!(
|
|
||||||
include_str!("sigsetjmp/x86_64/sigsetjmp.s"),
|
|
||||||
options(att_syntax)
|
|
||||||
);
|
|
||||||
|
|
||||||
unsafe extern "C" {
|
unsafe extern "C" {
|
||||||
pub fn sigsetjmp(jb: *mut u64, savemask: i32) -> i32;
|
pub fn sigsetjmp(jb: *mut u64, savemask: i32) -> i32;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# implementation of sigsetjmp
|
|
||||||
|
|
||||||
All code found in the subdirectories of this directory belong to [musl libc](https://musl.libc.org/). They own it. All rights go to them.
|
|
||||||
Currently only x86_64 is supported, because I don't have access to non-x86 devices to test it properly.
|
|
||||||
Converted to Intel assembly syntax, according to setjmp and longjmp found in setjmp header.
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
.global sigsetjmp
|
|
||||||
.global __sigsetjmp
|
|
||||||
.type sigsetjmp,@function
|
|
||||||
.type __sigsetjmp,@function
|
|
||||||
sigsetjmp:
|
|
||||||
__sigsetjmp:
|
|
||||||
mov 8(%esp),%ecx
|
|
||||||
jecxz 1f
|
|
||||||
|
|
||||||
mov 4(%esp),%eax
|
|
||||||
popl 24(%eax)
|
|
||||||
mov %ebx,28+8(%eax)
|
|
||||||
mov %eax,%ebx
|
|
||||||
|
|
||||||
.hidden ___setjmp
|
|
||||||
call ___setjmp
|
|
||||||
|
|
||||||
pushl 24(%ebx)
|
|
||||||
mov %ebx,4(%esp)
|
|
||||||
mov %eax,8(%esp)
|
|
||||||
mov 28+8(%ebx),%ebx
|
|
||||||
|
|
||||||
.hidden __sigsetjmp_tail
|
|
||||||
jmp __sigsetjmp_tail
|
|
||||||
|
|
||||||
1: jmp ___setjmp
|
|
||||||
Reference in New Issue
Block a user