[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:
Travis Geiselbrecht
2019-02-17 18:55:42 -08:00
parent 7ca88d22b5
commit dc2fe55fa9
2 changed files with 7 additions and 0 deletions

View File

@@ -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))

View File

@@ -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