diff --git a/arch/arm/lib64/runtime-offset.S b/arch/arm/lib64/runtime-offset.S index 6624fdf..5e5ab9a 100644 --- a/arch/arm/lib64/runtime-offset.S +++ b/arch/arm/lib64/runtime-offset.S @@ -1,31 +1,25 @@ #include #include -/* - * The .section directive below intentionally omits "a", since that - * appears to be the simplest way to force assembler to not generate - * R_AARCH64_RELATIVE relocation for - * - * linkadr: - * .quad get_runtime_offset - * - * statement below. While having that relocating was relatively - * harmless with GCC8, builging the code with GCC5 resulted in - * "linkaddr" being initialized to 0 causing complete boot breakdown - */ -.section ".text_bare_init","x" +.section ".text_bare_init","ax" /* * Get the offset between the link address and the address * we are currently running at. */ ENTRY(get_runtime_offset) -1: adr x0, 1b +1: adr x0, _text ldr x1, linkadr subs x0, x0, x1 ret .align 3 linkadr: -.quad get_runtime_offset +/* + * With older gcc versions (gcc5) function pointers will not be filled + * into the binary during compile time and instead rely on relocation + * during runtime. In the binary we'll always have 0x0 here. We deliberately + * use _text here since that is 0x0 and is correct without relocation. + */ +.quad _text ENDPROC(get_runtime_offset)