Skip to content

Commit 0f5f46a

Browse files
Song Shuaipalmer-dabbelt
authored andcommitted
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: 39b3307 ("riscv: Introduce CONFIG_RELOCATABLE") Signed-off-by: Song Shuai <songshuaishuai@tinylab.org> Link: https://lore.kernel.org/r/20230907103304.590739-4-songshuaishuai@tinylab.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 7674236 commit 0f5f46a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

arch/riscv/purgatory/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ ifdef CONFIG_STACKPROTECTOR_STRONG
7777
PURGATORY_CFLAGS_REMOVE += -fstack-protector-strong
7878
endif
7979

80+
ifdef CONFIG_RELOCATABLE
81+
PURGATORY_CFLAGS_REMOVE += -fPIE
82+
endif
83+
8084
CFLAGS_REMOVE_purgatory.o += $(PURGATORY_CFLAGS_REMOVE)
8185
CFLAGS_purgatory.o += $(PURGATORY_CFLAGS)
8286

0 commit comments

Comments
 (0)