Compare commits
No commits in common. "7d658ad704cdab7b23ea6c067ef2442a819f8572" and "ae7b904abc161d6fa0b4441ea6aabb6a5634a657" have entirely different histories.
7d658ad704
...
ae7b904abc
17
src/main.rs
17
src/main.rs
|
@ -15,16 +15,11 @@ unsafe extern "C" fn _enter() -> ! {
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
asm!(
|
asm!(
|
||||||
// before we use the `la` pseudo-instruction for the first time,
|
// before we use the `la` pseudo-instruction for the first time,
|
||||||
// we need to set `gp` (google linker relaxation)
|
// we need to set `gp` (google linker relaxation)
|
||||||
".option push", // pushes the current option stack
|
".option push",
|
||||||
".option norelax", // disable relaxation so we can properly set `gp`
|
".option norelax",
|
||||||
// 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",
|
"la gp, _global_pointer",
|
||||||
".option pop", // pops the current option stack
|
".option pop",
|
||||||
|
|
||||||
// set the stack pointer
|
// set the stack pointer
|
||||||
"la sp, _init_stack_top",
|
"la sp, _init_stack_top",
|
||||||
|
@ -72,9 +67,7 @@ extern "C" fn start() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn on_panic(info: &PanicInfo) -> ! {
|
fn on_panic(_info: &PanicInfo) -> ! {
|
||||||
println!("{}", info);
|
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ PHDRS {
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
. = ORIGIN(ram); # start at 0x8000_0000 (DRAM)
|
. = ORIGIN(ram); # start at 0x8000_0000
|
||||||
|
|
||||||
.text : { # put code first
|
.text : { # put code first
|
||||||
*(.text.init) # start with anything in the .text.init section
|
*(.text.init) # start with anything in the .text.init section
|
||||||
|
|
Loading…
Reference in a new issue