Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

riscv: Support R_RISCV_ADD64 and R_RISCV_SUB64 relocs

These are needed for the __jump_table in modules using
static keys/jump-labels with the layout from
HAVE_ARCH_JUMP_LABEL_RELATIVE on 64bit kernels.

Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
Reviewed-by: Björn Töpel <bjorn.topel@gmail.com>
Tested-by: Björn Töpel <bjorn.topel@gmail.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>

authored by

Emil Renner Berthing and committed by
Palmer Dabbelt
11a54f42 8e0c02f2

+16
+16
arch/riscv/kernel/module.c
··· 263 263 return 0; 264 264 } 265 265 266 + static int apply_r_riscv_add64_rela(struct module *me, u32 *location, 267 + Elf_Addr v) 268 + { 269 + *(u64 *)location += (u64)v; 270 + return 0; 271 + } 272 + 266 273 static int apply_r_riscv_sub32_rela(struct module *me, u32 *location, 267 274 Elf_Addr v) 268 275 { 269 276 *(u32 *)location -= (u32)v; 277 + return 0; 278 + } 279 + 280 + static int apply_r_riscv_sub64_rela(struct module *me, u32 *location, 281 + Elf_Addr v) 282 + { 283 + *(u64 *)location -= (u64)v; 270 284 return 0; 271 285 } 272 286 ··· 304 290 [R_RISCV_RELAX] = apply_r_riscv_relax_rela, 305 291 [R_RISCV_ALIGN] = apply_r_riscv_align_rela, 306 292 [R_RISCV_ADD32] = apply_r_riscv_add32_rela, 293 + [R_RISCV_ADD64] = apply_r_riscv_add64_rela, 307 294 [R_RISCV_SUB32] = apply_r_riscv_sub32_rela, 295 + [R_RISCV_SUB64] = apply_r_riscv_sub64_rela, 308 296 }; 309 297 310 298 int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,