u-boot/arch
Sean Anderson d9f1cee286 riscv: Fix breakage caused by linker relaxation
Due to the two-instruction sequence needed to access arbitrary memory
locations, the RISC-V linker aggressively optimises memory accesses and
jumps at link-time. This is called "linker relaxation," and is discussed
in this SiFive article
<https://www.sifive.com/blog/all-aboard-part-3-linker-relaxation-in-riscv-toolchain>.
One of the optimizations in place is to assume that the __global_pointer
symbol is placed in the gp register. To quote the article:

"...The magic __global_pointer$ symbol is defined to point 0x800 bytes
past the start of the .sdata section. The 0x800 magic number allows
signed 12-bit offsets from __global_pointer$ to address symbols at the
start of the .sdata section. The linker assumes that if this symbol is
defined, then the gp register contains that value, which it can then use
to relax accesses to global symbols within that 12-bit range. The
compiler treats the gp register as a constant so it doesn't need to be
saved or restored, which means it is generally only written by _start,
the ELF entry point."

However, U-Boot instead keeps the global data pointer in gp. This causes
memory accesses and jumps optimized to use the gp pointer to fail. To
fix this problem, we undefine the __global_pointer symbol.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
2020-02-10 14:50:53 +08:00
..
arc common: Move reset_cpu() to the CPU header 2020-01-24 23:06:49 +05:30
arm board: presidio-asic: Add basic G3 engr. development board support 2020-02-07 16:16:01 -05:00
m68k common: Move clock functions into a new file 2020-01-24 23:06:48 +05:30
microblaze common: Move hang() to the same header as panic() 2020-01-24 23:06:49 +05:30
mips common: Move hang() to the same header as panic() 2020-01-24 23:06:49 +05:30
nds32 asm: dma-mapping.h: Fix dma mapping functions 2020-01-25 12:04:36 -05:00
nios2 common: Move hang() to the same header as panic() 2020-01-24 23:06:49 +05:30
powerpc mpc8xx: Expose show_regs() 2020-02-07 13:59:58 -05:00
riscv riscv: Fix breakage caused by linker relaxation 2020-02-10 14:50:53 +08:00
sandbox common: Move hang() to the same header as panic() 2020-01-24 23:06:49 +05:30
sh common: Move reset_cpu() to the CPU header 2020-01-24 23:06:49 +05:30
x86 x86: itss: Remove apl-prefix 2020-02-04 12:54:54 +08:00
xtensa common: Move relocate_code() to init.h 2020-01-24 23:06:48 +05:30
.gitignore
Kconfig x86: Enable pinctrl in SPL and TPL 2019-12-15 11:44:24 +08:00