Skip to content

Commit 781c8fe

Browse files
andreas-schwabpalmer-dabbelt
authored andcommitted
RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations
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 <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 021c917 commit 781c8fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/kernel/module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ static int apply_r_riscv_align_rela(struct module *me, u32 *location,
263263
static int apply_r_riscv_add32_rela(struct module *me, u32 *location,
264264
Elf_Addr v)
265265
{
266-
*(u32 *)location += (*(u32 *)v);
266+
*(u32 *)location += (u32)v;
267267
return 0;
268268
}
269269

270270
static int apply_r_riscv_sub32_rela(struct module *me, u32 *location,
271271
Elf_Addr v)
272272
{
273-
*(u32 *)location -= (*(u32 *)v);
273+
*(u32 *)location -= (u32)v;
274274
return 0;
275275
}
276276

0 commit comments

Comments
 (0)