From: Andreas Schwab Date: Tue, 12 Jun 2018 17:26:36 +0000 (+0200) Subject: RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations X-Git-Tag: v4.17.19~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c488c3eabe9d6f9b2b705f8a68ba395b0eaea132;p=thirdparty%2Fkernel%2Fstable.git RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations [ Upstream commit 781c8fe2da3d2c7c95cd7ffddbab63b80a79da4d ] The R_RISCV_ADD32/R_RISCV_SUB32 relocations should add/subtract the address of the symbol (without overflow check), not its contents. Signed-off-by: Andreas Schwab Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c index 5dddba301d0a7..ac7600b8709a0 100644 --- a/arch/riscv/kernel/module.c +++ b/arch/riscv/kernel/module.c @@ -252,14 +252,14 @@ static int apply_r_riscv_align_rela(struct module *me, u32 *location, static int apply_r_riscv_add32_rela(struct module *me, u32 *location, Elf_Addr v) { - *(u32 *)location += (*(u32 *)v); + *(u32 *)location += (u32)v; return 0; } static int apply_r_riscv_sub32_rela(struct module *me, u32 *location, Elf_Addr v) { - *(u32 *)location -= (*(u32 *)v); + *(u32 *)location -= (u32)v; return 0; }