Skip to content

Commit bb58e15

Browse files
RISC-V: errata: Use medany for relocatable builds
We're trying to mix non-PIC/PIE objects into the otherwise-PIE relocatable kernels, to avoid GOT/PLT references during early boot alternative resolution (which happens before the GOT/PLT are set up). riscv64-unknown-linux-gnu-ld: arch/riscv/errata/sifive/errata.o: relocation R_RISCV_HI20 against `tlb_flush_all_threshold' can not be used when making a shared object; recompile with -fPIC riscv64-unknown-linux-gnu-ld: arch/riscv/errata/thead/errata.o: relocation R_RISCV_HI20 against `riscv_cbom_block_size' can not be used when making a shared object; recompile with -fPIC Fixes: 8dc2a7e ("riscv: Fix relocatable kernels with early alternatives using -fno-pie") Link: https://lore.kernel.org/r/20250326224506.27165-2-palmer@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 2014c95 commit bb58e15

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/riscv/errata/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
ifdef CONFIG_RELOCATABLE
2-
KBUILD_CFLAGS += -fno-pie
2+
# We can't use PIC/PIE when handling early-boot errata parsing, as the kernel
3+
# doesn't have a GOT setup at that point. So instead just use medany: it's
4+
# usually position-independent, so it should be good enough for the errata
5+
# handling.
6+
KBUILD_CFLAGS += -fno-pie -mcmodel=medany
37
endif
48

59
ifdef CONFIG_RISCV_ALTERNATIVE_EARLY

0 commit comments

Comments
 (0)