[arch][riscv] set up the global pointer register
The linker will automatically relax any dereferences and calculations for symbols located near the symbol __global_pointer$.
This commit is contained in:
@@ -67,6 +67,7 @@ SECTIONS
|
||||
/* in one segment binaries, the rom data address is on top of the ram data address */
|
||||
__data_start = .;
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
PROVIDE( __global_pointer$ = . + (4K / 2) );
|
||||
*(.sdata .sdata.*)
|
||||
__ctor_list = .;
|
||||
KEEP(*(.ctors .init_array))
|
||||
|
||||
@@ -44,6 +44,12 @@ _vectab:
|
||||
|
||||
.section ".text.boot"
|
||||
FUNCTION(_start)
|
||||
.option push
|
||||
.option norelax
|
||||
# set the global pointer
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
|
||||
# set the default stack
|
||||
la sp, default_stack_top
|
||||
|
||||
|
||||
Reference in New Issue
Block a user