Skip to content

Commit

Permalink
fix: the unknown relocation type 57
Browse files Browse the repository at this point in the history
Signed-off-by: Hanyuan Zhao <hanyuan-z@qq.com>
  • Loading branch information
gtxzsxxk committed Nov 19, 2023
1 parent ca0152f commit 842095e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/riscv/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ static int apply_r_riscv_sub64_rela(struct module *me, u32 *location,
return 0;
}

static int apply_r_riscv_pcrel_32_rela(struct module *me, u32 *location,
Elf_Addr v)
{
ptrdiff_t offset = (void *)v - (void *)location;
*location = (*location & 0xffff0000) | (offset & 0x0000ffff);
return 0;
}

static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
Elf_Addr v) = {
[R_RISCV_32] = apply_r_riscv_32_rela,
Expand All @@ -307,6 +315,7 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
[R_RISCV_ADD64] = apply_r_riscv_add64_rela,
[R_RISCV_SUB32] = apply_r_riscv_sub32_rela,
[R_RISCV_SUB64] = apply_r_riscv_sub64_rela,
[R_RISCV_32_PCREL] = apply_r_riscv_pcrel_32_rela,
};

static inline int apply_calc_pcrel_lo12(Elf_Shdr *sechdrs, Elf_Rela *rel,
Expand Down

0 comments on commit 842095e

Please sign in to comment.