Skip to content

Commit dcea253

Browse files
committed
Replace the bl! macro with asm_sym
`bl!` is being used to add a leading underscore on Apple targets. `asm_sym` has been around since 2022 and handles platform-specific symbol names automatically, so make use of this instead. I have verified that `armv7s-apple-ios` still builds correctly.
1 parent 962ae4b commit dcea253

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

Diff for: compiler-builtins/src/arm.rs

+8-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
#![cfg(not(feature = "no-asm"))]
2-
#![allow(unused_imports)]
3-
4-
use core::intrinsics;
5-
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-
}
192

203
intrinsics! {
214
// NOTE This function and the ones below are implemented using assembly because they are using a
@@ -27,10 +10,11 @@ intrinsics! {
2710
"push {{lr}}",
2811
"sub sp, sp, #4",
2912
"mov r2, sp",
30-
bl!("__udivmodsi4"),
13+
"bl {trampoline}",
3114
"ldr r1, [sp]",
3215
"add sp, sp, #4",
3316
"pop {{pc}}",
17+
trampoline = sym crate::int::udiv::__udivmodsi4
3418
);
3519
}
3620

@@ -41,23 +25,25 @@ intrinsics! {
4125
"sub sp, sp, #16",
4226
"add r4, sp, #8",
4327
"str r4, [sp]",
44-
bl!("__udivmoddi4"),
28+
"bl {trampoline}",
4529
"ldr r2, [sp, #8]",
4630
"ldr r3, [sp, #12]",
4731
"add sp, sp, #16",
4832
"pop {{r4, pc}}",
33+
trampoline = sym crate::int::udiv::__udivmoddi4
4934
);
5035
}
5136

5237
#[unsafe(naked)]
5338
pub unsafe extern "C" fn __aeabi_idivmod() {
5439
core::arch::naked_asm!(
5540
"push {{r0, r1, r4, lr}}",
56-
bl!("__aeabi_idiv"),
41+
"bl {trampoline}",
5742
"pop {{r1, r2}}",
5843
"muls r2, r2, r0",
5944
"subs r1, r1, r2",
6045
"pop {{r4, pc}}",
46+
trampoline = sym crate::arm::__aeabi_idivmod::__aeabi_idivmod,
6147
);
6248
}
6349

@@ -68,11 +54,12 @@ intrinsics! {
6854
"sub sp, sp, #16",
6955
"add r4, sp, #8",
7056
"str r4, [sp]",
71-
bl!("__divmoddi4"),
57+
"bl {trampoline}",
7258
"ldr r2, [sp, #8]",
7359
"ldr r3, [sp, #12]",
7460
"add sp, sp, #16",
7561
"pop {{r4, pc}}",
62+
trampoline = sym crate::int::sdiv::__divmoddi4,
7663
);
7764
}
7865

0 commit comments

Comments
 (0)