github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/device/riscv/start.S (about)

     1  .section .init
     2  .global _start
     3  .type _start,@function
     4  
     5  _start:
     6      // Load the stack pointer.
     7      la sp,      _stack_top
     8  
     9      // Load the globals pointer. The program will load pointers relative to this
    10      // register, so it must be set to the right value on startup.
    11      // See: https://gnu-mcu-eclipse.github.io/arch/riscv/programmer/#the-gp-global-pointer-register
    12      // Linker relaxations must be disabled to avoid the initialization beign
    13      // relaxed with an uninitialized global pointer: mv gp, gp
    14      .option push
    15      .option norelax
    16      la gp,      __global_pointer$
    17      .option pop
    18  
    19      // Jump to runtime.main
    20      call main