JayAurabind

LLD crash

Mar 4th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.00 KB | None | 0 0
  1. #![feature(global_asm)]
  2. #![no_main]
  3. #![no_std]
  4.  
  5. const LED_ADDRESS: u32 = 0x0300_0000;
  6.  
  7. use panic_abort;
  8.  
  9. // The reset handler
  10. #[no_mangle]
  11. #[link_section = ".Premain"]
  12. pub unsafe extern "C" fn Premain() -> ! {
  13.     r0::zero_bss(&mut _sbss, &mut _ebss);
  14.     r0::init_data(&mut _sdata, &mut _edata, &_sidata);
  15.     main()
  16. }
  17.  
  18. fn main() -> ! {
  19.  
  20.     loop {
  21.         for _ in 0..256 {
  22.             unsafe { core::ptr::write_volatile(LED_ADDRESS as *mut u32, 0xffff_ffff); }
  23.         }
  24.     }
  25. }
  26.  
  27. extern "C" {
  28.     // Boundaries of the .bss section
  29.     static mut _ebss: u32;
  30.     static mut _sbss: u32;
  31.  
  32.     // Boundaries of the .data section
  33.     static mut _edata: u32;
  34.     static mut _sdata: u32;
  35.  
  36.     // Initial values of the .data section (stored in Flash)
  37.     static _sidata: u32;
  38. }
  39.  
  40.  
  41. // Make sure there is an abort when linking
  42. #[cfg(target_arch = "riscv32")]
  43. global_asm!(r#"
  44. .section .text
  45. global Reset
  46. Reset:
  47. .option rvc
  48.     c.j Premain
  49.  
  50. .globl abort
  51. abort:
  52.  jal zero, abort
  53. "#);
Add Comment
Please, Sign In to add comment