Compare commits
4 commits
ae7b904abc
...
7d658ad704
Author | SHA1 | Date | |
---|---|---|---|
gil | 7d658ad704 | ||
gil | e409015ff8 | ||
gil | 2b80cb9a9b | ||
gil | 13fb110417 |
17
src/main.rs
17
src/main.rs
|
@ -15,11 +15,16 @@ unsafe extern "C" fn _enter() -> ! {
|
|||
use core::arch::asm;
|
||||
asm!(
|
||||
// before we use the `la` pseudo-instruction for the first time,
|
||||
// we need to set `gp` (google linker relaxation)
|
||||
".option push",
|
||||
".option norelax",
|
||||
// we need to set `gp` (google linker relaxation)
|
||||
".option push", // pushes the current option stack
|
||||
".option norelax", // disable relaxation so we can properly set `gp`
|
||||
// this instruction compiles to:
|
||||
// 1:
|
||||
// auipc gp, %pcrel_hi(_global_pointer)
|
||||
// addi gp, gp, %pcrel_lo(1b)
|
||||
// if relaxation were on, this would simply be `mv gp, gp` or `addi gp, gp, 0`
|
||||
"la gp, _global_pointer",
|
||||
".option pop",
|
||||
".option pop", // pops the current option stack
|
||||
|
||||
// set the stack pointer
|
||||
"la sp, _init_stack_top",
|
||||
|
@ -67,7 +72,9 @@ extern "C" fn start() -> ! {
|
|||
}
|
||||
|
||||
#[panic_handler]
|
||||
fn on_panic(_info: &PanicInfo) -> ! {
|
||||
fn on_panic(info: &PanicInfo) -> ! {
|
||||
println!("{}", info);
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ PHDRS {
|
|||
}
|
||||
|
||||
SECTIONS {
|
||||
. = ORIGIN(ram); # start at 0x8000_0000
|
||||
. = ORIGIN(ram); # start at 0x8000_0000 (DRAM)
|
||||
|
||||
.text : { # put code first
|
||||
*(.text.init) # start with anything in the .text.init section
|
||||
|
|
Loading…
Reference in a new issue