]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations
authorAndreas Schwab <schwab@suse.de>
Tue, 12 Jun 2018 17:26:36 +0000 (19:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Aug 2018 11:06:59 +0000 (13:06 +0200)
[ 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 <schwab@suse.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/riscv/kernel/module.c

index 5dddba301d0a726ff78e97acca1b051c123a8bb7..ac7600b8709a07aa21239a7ebcd8f86e56b1772e 100644 (file)
@@ -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;
 }