Browse Source

Fixes on s_mode_start

luojia65 4 years ago
parent
commit
7d5063ca8c
1 changed files with 7 additions and 11 deletions
  1. 7 11
      platform/qemu/src/main.rs

+ 7 - 11
platform/qemu/src/main.rs

@@ -211,28 +211,24 @@ fn main() -> ! {
         println!("[rustsbi] Kernel entry: 0x80200000");
     }
 
-    extern "C" {
-        fn _s_mode_start();
-    }
     unsafe {
-        mepc::write(_s_mode_start as usize);
+        mepc::write(s_mode_start as usize);
         mstatus::set_mpp(MPP::Supervisor);
         rustsbi::enter_privileged(mhartid::read(), dtb_pa)
     }
 }
 
-global_asm!(
-    "
-    .section .text
-    .globl _s_mode_start
-_s_mode_start:
+#[naked]
+#[link_section = ".text"] // must add link section for all naked functions
+unsafe extern "C" fn s_mode_start() -> ! {
+    asm!("
 1:  auipc ra, %pcrel_hi(1f)
     ld ra, %pcrel_lo(1b)(ra)
     jr ra
 .align  3
 1:  .dword 0x80200000
-"
-);
+    ", options(noreturn))
+}
 
 global_asm!(
     "