From 3d3432916aacf4950f4652cbf0e788576e3ed252 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Fri, 22 Jul 2022 17:14:18 -0600 Subject: [PATCH 1/2] add weak linkage to the ARM AEABI division functions --- src/arm.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arm.rs b/src/arm.rs index 9c1b6ad12..f3b22544a 100644 --- a/src/arm.rs +++ b/src/arm.rs @@ -22,6 +22,7 @@ intrinsics! { // custom calling convention which can't be implemented using a normal Rust function. #[naked] #[cfg(not(target_env = "msvc"))] + #[linkage = "weak"] pub unsafe extern "C" fn __aeabi_uidivmod() { core::arch::asm!( "push {{lr}}", @@ -36,6 +37,7 @@ intrinsics! { } #[naked] + #[linkage = "weak"] pub unsafe extern "C" fn __aeabi_uldivmod() { core::arch::asm!( "push {{r4, lr}}", @@ -52,6 +54,7 @@ intrinsics! { } #[naked] + #[linkage = "weak"] pub unsafe extern "C" fn __aeabi_idivmod() { core::arch::asm!( "push {{r0, r1, r4, lr}}", @@ -65,6 +68,7 @@ intrinsics! { } #[naked] + #[linkage = "weak"] pub unsafe extern "C" fn __aeabi_ldivmod() { core::arch::asm!( "push {{r4, lr}}", From c2a912422570eb9d6b6cc2db5a8ccb31f5aa0dd6 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Thu, 28 Jul 2022 09:42:18 -0600 Subject: [PATCH 2/2] restrict linkage to platforms using ELF binaries on windows and apple (which don't use ELF) we can't apply weak linkage --- src/arm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arm.rs b/src/arm.rs index f3b22544a..e517a9ef3 100644 --- a/src/arm.rs +++ b/src/arm.rs @@ -22,7 +22,7 @@ intrinsics! { // custom calling convention which can't be implemented using a normal Rust function. #[naked] #[cfg(not(target_env = "msvc"))] - #[linkage = "weak"] + #[cfg_attr(all(not(windows), not(target_vendor="apple")), linkage = "weak")] pub unsafe extern "C" fn __aeabi_uidivmod() { core::arch::asm!( "push {{lr}}", @@ -37,7 +37,7 @@ intrinsics! { } #[naked] - #[linkage = "weak"] + #[cfg_attr(all(not(windows), not(target_vendor="apple")), linkage = "weak")] pub unsafe extern "C" fn __aeabi_uldivmod() { core::arch::asm!( "push {{r4, lr}}", @@ -54,7 +54,7 @@ intrinsics! { } #[naked] - #[linkage = "weak"] + #[cfg_attr(all(not(windows), not(target_vendor="apple")), linkage = "weak")] pub unsafe extern "C" fn __aeabi_idivmod() { core::arch::asm!( "push {{r0, r1, r4, lr}}", @@ -68,7 +68,7 @@ intrinsics! { } #[naked] - #[linkage = "weak"] + #[cfg_attr(all(not(windows), not(target_vendor="apple")), linkage = "weak")] pub unsafe extern "C" fn __aeabi_ldivmod() { core::arch::asm!( "push {{r4, lr}}",