[PATCH master 0/3] Fix GCC 11 THUMB2 relocate_to_current_adr miscompile
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Oct 13 02:03:49 PDT 2022
TL;DR: GCC can prove that variables aren't supposed to overlap and as
such it generated code than readded get_runtime_offset() on top of an
already relocated linker-defined variable's address.
See PATCH 2/3 for a disassembly of the affected code. Board code can
be similarly micompiled, but that's a fix for another day.
I am not so sure about the name of the new macro. I chose
get_unrelocated for similarity with get_unaligned, but it doesn't
dereference the argument, just get its address. Looking at it that way,
it's just a UB-infested way to say & (address-of). Perhaps just
call it runtime_address()? After all, it works before and after
relocation. We can change that later though, once I get around
to patch board entry points.
Ahmad Fatoum (3):
include: asm-generic: reloc: implement get_unrelocated()
ARM: cpu: add compiler barrier around unrelocated access
RISC-V: add compiler barriers around unrelocated accesses
arch/arm/cpu/common.c | 11 +++--
arch/arm/cpu/uncompress.c | 4 +-
arch/riscv/boot/uncompress.c | 4 +-
arch/riscv/include/asm/sections.h | 2 +-
arch/riscv/lib/reloc.c | 6 +--
include/asm-generic/reloc.h | 68 +++++++++++++++++++++++++++++++
6 files changed, 81 insertions(+), 14 deletions(-)
--
2.30.2
More information about the barebox
mailing list