linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: relocate R_RISCV_CALL_PLT in kexec_file
@ 2023-03-10 18:27 Torsten Duwe
  2023-03-13  3:13 ` Li Zhengyu
  0 siblings, 1 reply; 5+ messages in thread
From: Torsten Duwe @ 2023-03-10 18:27 UTC (permalink / raw)
  To: Li Zhengyu, Paul Walmsley, Conor Dooley, Palmer Dabbelt
  Cc: Albert Ou, Li Huafei, Liao Chang, linux-riscv, linux-kernel

Depending on the toolchain (here: gcc-12, binutils-2.40) the
relocation entries for function calls are no longer R_RISCV_CALL, but
R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will
fail with

 kexec_image: Unknown rela relocation: 19
 kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell
arch_kexec_apply_relocations_add() to handle _PLT alike.

fixes: 838b3e28488f702 ("Load purgatory in kexec_file")
Signed-off-by: Torsten Duwe <duwe@suse.de>
Cc: stable@vger.kernel.org

---
--- a/arch/riscv/kernel/elf_kexec.c
+++ b/arch/riscv/kernel/elf_kexec.c
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
 		 * sym, instead of searching the whole relsec.
 		 */
 		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
 		case R_RISCV_CALL:
 			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
 				 ENCODE_UJTYPE_IMM(val - addr);

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-23 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 18:27 [PATCH] riscv: relocate R_RISCV_CALL_PLT in kexec_file Torsten Duwe
2023-03-13  3:13 ` Li Zhengyu
2023-03-21 15:03   ` Torsten Duwe
2023-03-21 15:35     ` Conor Dooley
2023-07-23 10:27       ` Conor Dooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).