Skip to content

Commit 6fb9dc3

Browse files
committed
Replace bl! with sym in arm trampolines
`bl!` exists to account for the leading `_` in Apple symbols. Switch to using `sym` which does this implicitly.
1 parent f6a6911 commit 6fb9dc3

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/arm.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@
33

44
use core::intrinsics;
55

6-
// Apple symbols have a leading underscore.
7-
#[cfg(target_vendor = "apple")]
8-
macro_rules! bl {
9-
($func:literal) => {
10-
concat!("bl _", $func)
11-
};
12-
}
13-
#[cfg(not(target_vendor = "apple"))]
14-
macro_rules! bl {
15-
($func:literal) => {
16-
concat!("bl ", $func)
17-
};
18-
}
19-
206
intrinsics! {
217
// NOTE This function and the ones below are implemented using assembly because they are using a
228
// custom calling convention which can't be implemented using a normal Rust function.
@@ -27,10 +13,11 @@ intrinsics! {
2713
"push {{lr}}",
2814
"sub sp, sp, #4",
2915
"mov r2, sp",
30-
bl!("__udivmodsi4"),
16+
"bl {func}",
3117
"ldr r1, [sp]",
3218
"add sp, sp, #4",
3319
"pop {{pc}}",
20+
func = sym crate::int::udiv::__udivmodsi4,
3421
);
3522
}
3623

@@ -41,23 +28,25 @@ intrinsics! {
4128
"sub sp, sp, #16",
4229
"add r4, sp, #8",
4330
"str r4, [sp]",
44-
bl!("__udivmoddi4"),
31+
"bl {func}",
4532
"ldr r2, [sp, #8]",
4633
"ldr r3, [sp, #12]",
4734
"add sp, sp, #16",
4835
"pop {{r4, pc}}",
36+
func = sym crate::int::udiv::__udivmoddi4,
4937
);
5038
}
5139

5240
#[naked]
5341
pub unsafe extern "C" fn __aeabi_idivmod() {
5442
core::arch::naked_asm!(
5543
"push {{r0, r1, r4, lr}}",
56-
bl!("__aeabi_idiv"),
44+
"bl {func}",
5745
"pop {{r1, r2}}",
5846
"muls r2, r2, r0",
5947
"subs r1, r1, r2",
6048
"pop {{r4, pc}}",
49+
func = sym crate::int::sdiv::__aeabi_idiv::__aeabi_idiv,
6150
);
6251
}
6352

@@ -68,11 +57,12 @@ intrinsics! {
6857
"sub sp, sp, #16",
6958
"add r4, sp, #8",
7059
"str r4, [sp]",
71-
bl!("__divmoddi4"),
60+
"bl {func}",
7261
"ldr r2, [sp, #8]",
7362
"ldr r3, [sp, #12]",
7463
"add sp, sp, #16",
7564
"pop {{r4, pc}}",
65+
func = sym crate::int::sdiv::__divmoddi4,
7666
);
7767
}
7868

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ macro_rules! intrinsics {
342342
}
343343

344344
#[cfg(all(target_arch = "arm", not(feature = "mangled-names")))]
345-
mod $alias {
345+
pub(crate) mod $alias {
346346
#[no_mangle]
347347
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
348348
$(#[$($attr)*])*
349-
extern "aapcs" fn $alias( $($argname: $ty),* ) $(-> $ret)? {
349+
pub(crate) extern "aapcs" fn $alias( $($argname: $ty),* ) $(-> $ret)? {
350350
super::$name($($argname),*)
351351
}
352352
}

0 commit comments

Comments
 (0)