Skip to content

Commit b1dc55a

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: Add support for 64_PCREL relocation type
When build and update kernel with the latest upstream binutils and loongson3_defconfig, module loader fails with: kmod: zsmalloc: Unknown relocation type 109 kmod: fuse: Unknown relocation type 109 kmod: fuse: Unknown relocation type 109 kmod: radeon: Unknown relocation type 109 kmod: nf_tables: Unknown relocation type 109 kmod: nf_tables: Unknown relocation type 109 This is because the latest upstream binutils replaces a pair of ADD64 and SUB64 with 64_PCREL, so add support for 64_PCREL relocation type. Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb Cc: <[email protected]> Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent c1c2ce2 commit b1dc55a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/loongarch/kernel/module.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,15 @@ static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_Addr v,
376376
return 0;
377377
}
378378

379+
static int apply_r_larch_64_pcrel(struct module *mod, u32 *location, Elf_Addr v,
380+
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
381+
{
382+
ptrdiff_t offset = (void *)v - (void *)location;
383+
384+
*(u64 *)location = offset;
385+
return 0;
386+
}
387+
379388
/*
380389
* reloc_handlers_rela() - Apply a particular relocation to a module
381390
* @mod: the module to apply the reloc to
@@ -406,6 +415,7 @@ static reloc_rela_handler reloc_rela_handlers[] = {
406415
[R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub,
407416
[R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala,
408417
[R_LARCH_32_PCREL] = apply_r_larch_32_pcrel,
418+
[R_LARCH_64_PCREL] = apply_r_larch_64_pcrel,
409419
};
410420

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

0 commit comments

Comments
 (0)