All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations
@ 2018-06-12 17:26 Andreas Schwab
  2018-06-12 19:38 ` Palmer Dabbelt
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2018-06-12 17:26 UTC (permalink / raw)
  To: linux-riscv

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>
---
 arch/riscv/kernel/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 29d265d0cf..46aacf6148 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -265,14 +265,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;
 }
 
-- 
2.17.1


-- 
Andreas Schwab, SUSE Labs, schwab at suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations
  2018-06-12 17:26 [PATCH] RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations Andreas Schwab
@ 2018-06-12 19:38 ` Palmer Dabbelt
  0 siblings, 0 replies; 2+ messages in thread
From: Palmer Dabbelt @ 2018-06-12 19:38 UTC (permalink / raw)
  To: linux-riscv

On Tue, 12 Jun 2018 10:26:36 PDT (-0700), schwab at suse.de wrote:
> 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>
> ---
>  arch/riscv/kernel/module.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
> index 29d265d0cf..46aacf6148 100644
> --- a/arch/riscv/kernel/module.c
> +++ b/arch/riscv/kernel/module.c
> @@ -265,14 +265,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;
>  }

Oops, sorry I missed those.  The entire relocation set might be worth a 
once-over, as there's a lot of bit twiddling in here and I wouldn't be 
surprised if I missed something else as well.

The RISC-V merge window has closed (I tag on Monday, let it bake until 
Wednesday, and then submit the PR), so I'll target this for my post-RC1 pull 
request.

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-12 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 17:26 [PATCH] RISC-V: fix R_RISCV_ADD32/R_RISCV_SUB32 relocations Andreas Schwab
2018-06-12 19:38 ` Palmer Dabbelt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.