Skip to content

Commit 9dc3af1

Browse files
committed
fix(rt): use #[unsafe(naked)] to ensure unsafety of naked functions
Remove nightly features as they are to be stablized in the following Rust releases. Ref: rust-lang/rust#134213 Signed-off-by: Zhouqi Jiang <[email protected]>
1 parent 5bcb3a5 commit 9dc3af1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sophgo-rom-rt/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![no_std]
2-
#![feature(naked_functions, asm_const)]
32

43
pub use sophgo_rom_rt_macros::entry;
54

@@ -145,7 +144,7 @@ impl sophgo_hal::uart::UartExt<3> for UART3 {}
145144
impl sophgo_hal::uart::UartExt<4> for UART4 {}
146145

147146
#[cfg(target_arch = "riscv64")]
148-
use core::arch::asm;
147+
use core::arch::naked_asm;
149148

150149
#[cfg(target_arch = "riscv64")]
151150
const LEN_STACK: usize = 1 * 1024;
@@ -158,13 +157,13 @@ const LEN_STACK: usize = 1 * 1024;
158157
pub struct Stack<const N: usize>([u8; N]);
159158

160159
#[cfg(target_arch = "riscv64")]
161-
#[naked]
160+
#[unsafe(naked)]
162161
#[link_section = ".text.entry"]
163162
#[export_name = "_start"]
164163
unsafe extern "C" fn entry() -> ! {
165164
#[link_section = ".bss.uninit"]
166165
static mut STACK: Stack<LEN_STACK> = Stack([0; LEN_STACK]);
167-
asm!(
166+
naked_asm!(
168167
".option push
169168
.option arch, -c
170169
j 1f
@@ -212,7 +211,6 @@ unsafe extern "C" fn entry() -> ! {
212211
stack = sym STACK,
213212
hart_stack_size = const LEN_STACK,
214213
main = sym main,
215-
options(noreturn)
216214
)
217215
}
218216

0 commit comments

Comments
 (0)