Skip to contentSkip to conversation

risc-v: Handle R_RISCV_CALL_PLT reloc

PATCH In review Khem Raj 2 participants 2 messages Feb 23, 2023 – Feb 28, 2023 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 risc-v: Handle R_RISCV_CALL_PLT reloc

GNU assembler starting 2.40 release always generates R_RISCV_CALL_PLT reloc for call in assembler [1], similarly llvm does not make distinction between R_RISCV_CALL_PLT and R_RISCV_CALL [2]

Fixes
grub-mkimage: error: relocation 0x13 is not implemented yet.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=70f35d72ef04cd23771875c1661c9975044a749c
[2] https://reviews.llvm.org/D132530

---
 grub-core/kern/riscv/dl.c | 1 +
 util/grub-mkimagexx.c     | 2 ++
 2 files changed, 3 insertions(+)
grub-core/kern/riscv/dl.c +1 -0
index f26b12aaa..896653bb4 100644
@@ -188,6 +188,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 	  break;
 
 	case R_RISCV_CALL:
+	case R_RISCV_CALL_PLT:
 	  {
 	    grub_uint32_t *abs_place = place;
 	    grub_ssize_t off = sym_addr - (grub_addr_t) place;
util/grub-mkimagexx.c +2 -0
index a1927e786..c5fb336e9 100644
@@ -1294,6 +1294,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
 		     }
 		     break;
 		   case R_RISCV_CALL:
+		   case R_RISCV_CALL_PLT:
 		     {
 		       grub_uint32_t hi20, lo12;
 
@@ -1726,6 +1727,7 @@ translate_relocation_pe (struct translate_context *ctx,
 	case R_RISCV_BRANCH:
 	case R_RISCV_JAL:
 	case R_RISCV_CALL:
+	case R_RISCV_CALL_PLT:
 	case R_RISCV_PCREL_HI20:
 	case R_RISCV_PCREL_LO12_I:
 	case R_RISCV_PCREL_LO12_S:
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Khem Raj

GNU assembler starting 2.40 release always generates R_RISCV_CALL_PLT reloc for call in assembler [1], similarly llvm does not make distinction between R_RISCV_CALL_PLT and R_RISCV_CALL [2]

Fixes
grub-mkimage: error: relocation 0x13 is not implemented yet.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=70f35d72ef04cd23771875c1661c9975044a749c
[2] https://reviews.llvm.org/D132530

Daniel