Fix static linker error caused by setjmp aarch64

This commit is contained in:
Wildan M
2026-03-03 10:37:07 +07:00
parent 760f67a8f2
commit 31c8d87a7c
+15 -1
View File
@@ -2,7 +2,9 @@
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/setjmp.h.html>.
use core::arch::global_asm;
use core::{arch::global_asm, ffi::c_int};
use crate::header::signal::sigsetjmp;
macro_rules! platform_specific {
($($rust_arch:expr,$c_arch:expr,$ext:expr;)+) => {
@@ -29,3 +31,15 @@ unsafe extern "C" {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/longjmp.html>.
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);
}
}