ARM: aarch64: Fix get_runtime_offset after relocation
get_runtime_offset shall return the offset between the address we are
running at and the address we are linked at. This value obviously
changes when we relocate the binary. cf3b09737b tried to avoid using
R_AARCH64_RELATIVE relocations, but in fact this is exactly what the
function needs to work. Consider barebox starting at 0x10000000
when we are linked at 0x0 then get_runtime_offset() should return
0x10000000 before relocate_to_current_adr(), but afterwards it should
return 0x0.

This patch brings back the previously removed "a" flag. Since gcc5
doesn't put the values of R_AARCH64_RELATIVE fixup'd relocations
into the binary but zeroes instead, we help ourselves by basing
get_runtime_offset on an address which actually is zero. With
CONFIG_RELOCATABLE=y the binary is always linked to 0x0, so _text
is initially zero.

Tested with gcc-5.4.0 (which was "fixed" by cf3b09737b) and gcc-8.2.1.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
1 parent fab26e6 commit 5f04e5e03e941c8cae4f42f670abba847bfbcf9d
@Sascha Hauer Sascha Hauer authored on 22 Aug 2019
Showing 1 changed file
View
arch/arm/lib64/runtime-offset.S