[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20231011083132.2428720-3-songshuaishuai@tinylab.org>
Date: Wed, 11 Oct 2023 16:31:32 +0800
From: Song Shuai <songshuaishuai@...ylab.org>
To: paul.walmsley@...ive.com, palmer@...belt.com,
aou@...s.berkeley.edu, conor.dooley@...rochip.com,
lihuafei1@...wei.com, songshuaishuai@...ylab.org,
petr.tesarik.ext@...wei.com, duwe@...e.de, ribalda@...omium.org,
akpm@...ux-foundation.org, keescook@...omium.org, hi@...ssa.is,
heiko@...ech.de, alexghiti@...osinc.com, schwab@...e.de
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
kexec@...ts.infradead.org
Subject: [PATCH 2/2] riscv: kexec: Remove -fPIE for PURGATORY_CFLAGS
With CONFIG_RELOCATABLE enabled, KBUILD_CFLAGS had a -fPIE option
and then the purgatory/string.o was built to reference _ctype symbol
via R_RISCV_GOT_HI20 relocations which can't be handled by purgatory.
As a consequence, the kernel failed kexec_load_file() with:
[ 880.386562] kexec_image: The entry point of kernel at 0x80200000
[ 880.388650] kexec_image: Unknown rela relocation: 20
[ 880.389173] kexec_image: Error loading purgatory ret=-8
So remove the -fPIE option for PURGATORY_CFLAGS to generate
R_RISCV_PCREL_HI20 relocations type making puragtory work as it was.
Fixes: 39b33072941f ("riscv: Introduce CONFIG_RELOCATABLE")
Signed-off-by: Song Shuai <songshuaishuai@...ylab.org>
---
arch/riscv/purgatory/Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile
index 9e6476719abb..982fc8e77108 100644
--- a/arch/riscv/purgatory/Makefile
+++ b/arch/riscv/purgatory/Makefile
@@ -81,6 +81,10 @@ ifdef CONFIG_CFI_CLANG
PURGATORY_CFLAGS_REMOVE += $(CC_FLAGS_CFI)
endif
+ifdef CONFIG_RELOCATABLE
+PURGATORY_CFLAGS_REMOVE += -fPIE
+endif
+
CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)
CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)
--
2.20.1
Powered by blists - more mailing lists