Skip to content

Commit 10cc3c3

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 614ab5e commit 10cc3c3

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

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

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#![cfg(not(feature = "no-asm"))]
2-
#![allow(unused_imports)]
32

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-
};
3+
// Interfaces used by naked trampolines. The signatures are not correct, but this does not matter
4+
// since we implement the calling convention by hand.
5+
extern "C" {
6+
fn __udivmodsi4();
7+
fn __udivmoddi4();
8+
fn __divmoddi4();
9+
fn __aeabi_idiv();
1810
}
1911

2012
intrinsics! {
@@ -27,10 +19,11 @@ intrinsics! {
2719
"push {{lr}}",
2820
"sub sp, sp, #4",
2921
"mov r2, sp",
30-
bl!("__udivmodsi4"),
22+
"bl {trampoline}",
3123
"ldr r1, [sp]",
3224
"add sp, sp, #4",
3325
"pop {{pc}}",
26+
trampoline = sym crate::arm::__udivmodsi4
3427
);
3528
}
3629

@@ -41,23 +34,25 @@ intrinsics! {
4134
"sub sp, sp, #16",
4235
"add r4, sp, #8",
4336
"str r4, [sp]",
44-
bl!("__udivmoddi4"),
37+
"bl {trampoline}",
4538
"ldr r2, [sp, #8]",
4639
"ldr r3, [sp, #12]",
4740
"add sp, sp, #16",
4841
"pop {{r4, pc}}",
42+
trampoline = sym crate::arm::__udivmoddi4
4943
);
5044
}
5145

5246
#[unsafe(naked)]
5347
pub unsafe extern "C" fn __aeabi_idivmod() {
5448
core::arch::naked_asm!(
5549
"push {{r0, r1, r4, lr}}",
56-
bl!("__aeabi_idiv"),
50+
"bl {trampoline}",
5751
"pop {{r1, r2}}",
5852
"muls r2, r2, r0",
5953
"subs r1, r1, r2",
6054
"pop {{r4, pc}}",
55+
trampoline = sym crate::arm::__aeabi_idiv,
6156
);
6257
}
6358

@@ -68,11 +63,12 @@ intrinsics! {
6863
"sub sp, sp, #16",
6964
"add r4, sp, #8",
7065
"str r4, [sp]",
71-
bl!("__divmoddi4"),
66+
"bl {trampoline}",
7267
"ldr r2, [sp, #8]",
7368
"ldr r3, [sp, #12]",
7469
"add sp, sp, #16",
7570
"pop {{r4, pc}}",
71+
trampoline = sym crate::arm::__divmoddi4,
7672
);
7773
}
7874

0 commit comments

Comments
 (0)