Skip to content

Commit 11a54f4

Browse files
esmilpalmer-dabbelt
authored andcommitted
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 <[email protected]> Reviewed-by: Björn Töpel <[email protected]> Tested-by: Björn Töpel <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 8e0c02f commit 11a54f4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

arch/riscv/kernel/module.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,27 @@ static int apply_r_riscv_add32_rela(struct module *me, u32 *location,
263263
return 0;
264264
}
265265

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+
266273
static int apply_r_riscv_sub32_rela(struct module *me, u32 *location,
267274
Elf_Addr v)
268275
{
269276
*(u32 *)location -= (u32)v;
270277
return 0;
271278
}
272279

280+
static int apply_r_riscv_sub64_rela(struct module *me, u32 *location,
281+
Elf_Addr v)
282+
{
283+
*(u64 *)location -= (u64)v;
284+
return 0;
285+
}
286+
273287
static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
274288
Elf_Addr v) = {
275289
[R_RISCV_32] = apply_r_riscv_32_rela,
@@ -290,7 +304,9 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
290304
[R_RISCV_RELAX] = apply_r_riscv_relax_rela,
291305
[R_RISCV_ALIGN] = apply_r_riscv_align_rela,
292306
[R_RISCV_ADD32] = apply_r_riscv_add32_rela,
307+
[R_RISCV_ADD64] = apply_r_riscv_add64_rela,
293308
[R_RISCV_SUB32] = apply_r_riscv_sub32_rela,
309+
[R_RISCV_SUB64] = apply_r_riscv_sub64_rela,
294310
};
295311

296312
int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,

0 commit comments

Comments
 (0)