u-boot/arch/arm
Kunihiko Hayashi 534f0fbd65 arm64: Fix relocation of env_addr if POSITION_INDEPENDENT=y
If both POSITION_INDEPENDENT and SYS_RELOC_GD_ENV_ADDR are enabled,
wherever original env is placed anywhere, it should be relocated to
the right address.

Relocation offset gd->reloc_off is calculated with SYS_TEXT_BASE in
setup_reloc() and env address gd->env_addr is relocated by the offset in
initr_reloc_global_data().

gd->env_addr
  = (orig env) + gd->reloc_off
  = (orig env) + (gd->relocaddr - SYS_TEXT_BASE)

However, SYS_TEXT_BASE isn't always runtime base address when
POSITION_INDEPENDENT is enabled. So the relocated env_addr might point to
wrong address. For example, if SYS_TEXT_BASE is zero, gd->env_addr is
out of memory location and memory exception will occur.

There is a difference between linked address such as SYS_TEXT_BASE and
runtime base address. In _main, the difference is calculated as
"run-vs-link" offset. The env_addr should also be added to the offset
to fix the address.

gd->env_addr
  = (orig env) + ("run-vs-link" offset)   + gd->reloc_off
  = (orig env) + (SYS_TEXT_BASE - _start) + (gd->relocaddr - SYS_TEXT_BASE)
  = (orig env) + (gd->relocaddr - _start)

Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Acked-by: Marek Vasut <marex@denx.de>
Tested-by: Marek Vasut <marex@denx.de>
2021-06-28 14:47:10 -04:00
..
cpu armv8: Update erratum number to align with doc 2021-06-17 11:46:11 +05:30
dts o4-imx-nano: Fix dtc warnings 2021-06-21 13:31:40 +02:00
include global_data: Ensure we have <config.h> when symbols are not in Kconfig yet 2021-06-23 08:45:03 -04:00
lib arm64: Fix relocation of env_addr if POSITION_INDEPENDENT=y 2021-06-28 14:47:10 -04:00
mach-aspeed common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
mach-at91 treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
mach-bcm283x reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-bcmstb
mach-cortina
mach-davinci reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-exynos ARM: make gd a function call for LTO and set via set_gd() 2021-05-24 14:21:30 -04:00
mach-highbank
mach-imx mx7d: Add Storopack's SMEGW01 board 2021-06-09 13:34:38 +02:00
mach-integrator
mach-ipq40xx dm: treewide: Rename auto_alloc_size members to be shorter 2020-12-13 08:00:25 -07:00
mach-k3 treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
mach-keystone ARM: fix LTO for keystone 2021-05-24 14:21:30 -04:00
mach-kirkwood drivers: ata: Remove mvsata_ide driver 2021-04-10 07:59:30 -04:00
mach-lpc32xx reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-mediatek board: mt7629: enable compression of u-boot to reduce the size of final image 2021-03-20 16:24:27 -04:00
mach-meson arm: meson: remove static ethernet link setup 2021-04-06 11:10:29 +02:00
mach-mvebu arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function 2021-06-04 11:32:41 +02:00
mach-nexell treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
mach-octeontx reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-octeontx2 reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-omap2 ARM: omap3: fix LTO for DM3730 (and possibly other omap3 boards) 2021-05-24 14:21:30 -04:00
mach-orion5x reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-owl reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-qemu qemu: arm: Initialise virtio devices in board_late_init 2020-12-31 14:41:31 +01:00
mach-rmobile ARM: rmobile: beacon: Set CONFIG_RZ_G2 on Beacon boards 2021-06-24 20:22:31 +02:00
mach-rockchip ARM: fix LTO for rockchip and samsung 2021-05-24 14:21:30 -04:00
mach-s5pc1xx
mach-snapdragon common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
mach-socfpga treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
mach-sti
mach-stm32 board: Add rt-thread art-pi board support 2021-04-09 11:53:00 +02:00
mach-stm32mp Add rt-thread art-pi board support based on STM32H750 SoC 2021-04-09 13:10:59 -04:00
mach-sunxi treewide: Convert macro and uses of __section(foo) to __section("foo") 2021-05-24 14:21:30 -04:00
mach-tegra ARM: fix LTO for seaboard 2021-05-24 14:21:30 -04:00
mach-u8500
mach-uniphier reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-versal arm64: versal: Remove gd reference 2021-04-23 08:49:19 +02:00
mach-versatile
mach-zynq reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
mach-zynqmp arm64: zynqmp: Writing correct value to ANALOG_BUS 2021-06-11 09:24:58 +02:00
mach-zynqmp-r5 reset: Remove addr parameter from reset_cpu() 2021-03-02 14:03:02 -05:00
thumb1/include/asm/proc-armv
config.mk ARM: don't use --gc-sections with LTO when using private libgcc 2021-05-24 14:21:30 -04:00
Kconfig Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq 2021-06-17 08:44:56 -04:00
Kconfig.debug
Makefile