explain some of the .option directives in _enter()

This commit is contained in:
gil 2024-05-15 23:33:36 -05:00
parent e409015ff8
commit 7d658ad704

View file

@ -16,10 +16,15 @@ unsafe extern "C" fn _enter() -> ! {
asm!(
// before we use the `la` pseudo-instruction for the first time,
// we need to set `gp` (google linker relaxation)
".option push",
".option norelax",
".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",