Loading arch/riscv/kernel/module.c +22 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,27 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location, return 0; } static int apply_r_riscv_call_rela(struct module *me, u32 *location, Elf_Addr v) { s64 offset = (void *)v - (void *)location; s32 fill_v = offset; u32 hi20, lo12; if (offset != fill_v) { pr_err( "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", me->name, v, location); return -EINVAL; } hi20 = (offset + 0x800) & 0xfffff000; lo12 = (offset - hi20) & 0xfff; *location = (*location & 0xfff) | hi20; *(location + 1) = (*(location + 1) & 0xfffff) | (lo12 << 20); return 0; } static int apply_r_riscv_relax_rela(struct module *me, u32 *location, Elf_Addr v) { Loading @@ -157,6 +178,7 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location, [R_RISCV_PCREL_LO12_S] = apply_r_riscv_pcrel_lo12_s_rela, [R_RISCV_GOT_HI20] = apply_r_riscv_got_hi20_rela, [R_RISCV_CALL_PLT] = apply_r_riscv_call_plt_rela, [R_RISCV_CALL] = apply_r_riscv_call_rela, [R_RISCV_RELAX] = apply_r_riscv_relax_rela, }; Loading Loading
arch/riscv/kernel/module.c +22 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,27 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location, return 0; } static int apply_r_riscv_call_rela(struct module *me, u32 *location, Elf_Addr v) { s64 offset = (void *)v - (void *)location; s32 fill_v = offset; u32 hi20, lo12; if (offset != fill_v) { pr_err( "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n", me->name, v, location); return -EINVAL; } hi20 = (offset + 0x800) & 0xfffff000; lo12 = (offset - hi20) & 0xfff; *location = (*location & 0xfff) | hi20; *(location + 1) = (*(location + 1) & 0xfffff) | (lo12 << 20); return 0; } static int apply_r_riscv_relax_rela(struct module *me, u32 *location, Elf_Addr v) { Loading @@ -157,6 +178,7 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location, [R_RISCV_PCREL_LO12_S] = apply_r_riscv_pcrel_lo12_s_rela, [R_RISCV_GOT_HI20] = apply_r_riscv_got_hi20_rela, [R_RISCV_CALL_PLT] = apply_r_riscv_call_plt_rela, [R_RISCV_CALL] = apply_r_riscv_call_rela, [R_RISCV_RELAX] = apply_r_riscv_relax_rela, }; Loading