Skip to content

Commit c1c2ce2

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: Add support for 32_PCREL relocation type
When build and update kernel with the latest upstream binutils and loongson3_defconfig, module loader fails with: kmod: zsmalloc: Unsupport relocation type 99, please add its support. kmod: fuse: Unsupport relocation type 99, please add its support. kmod: ipmi_msghandler: Unsupport relocation type 99, please add its support. kmod: ipmi_msghandler: Unsupport relocation type 99, please add its support. kmod: pstore: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. kmod: drm_display_helper: Unsupport relocation type 99, please add its support. kmod: fuse: Unsupport relocation type 99, please add its support. kmod: fat: Unsupport relocation type 99, please add its support. This is because the latest upstream binutils replaces a pair of ADD32 and SUB32 with 32_PCREL, so add support for 32_PCREL relocation type. Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb Cc: <[email protected]> Co-developed-by: Youling Tang <[email protected]> Signed-off-by: Youling Tang <[email protected]> Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 2761498 commit c1c2ce2

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
@@ -367,6 +367,15 @@ static int apply_r_larch_got_pc(struct module *mod,
367367
return apply_r_larch_pcala(mod, location, got, rela_stack, rela_stack_top, type);
368368
}
369369

370+
static int apply_r_larch_32_pcrel(struct module *mod, u32 *location, Elf_Addr v,
371+
s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
372+
{
373+
ptrdiff_t offset = (void *)v - (void *)location;
374+
375+
*(u32 *)location = offset;
376+
return 0;
377+
}
378+
370379
/*
371380
* reloc_handlers_rela() - Apply a particular relocation to a module
372381
* @mod: the module to apply the reloc to
@@ -396,6 +405,7 @@ static reloc_rela_handler reloc_rela_handlers[] = {
396405
[R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field,
397406
[R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub,
398407
[R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala,
408+
[R_LARCH_32_PCREL] = apply_r_larch_32_pcrel,
399409
};
400410

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

0 commit comments

Comments
 (0)