Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Support 32_PCREL relocation type in kernel module
@ 2023-06-13  7:26 Nylon Chen
  2023-06-13 16:50 ` Conor Dooley
  0 siblings, 1 reply; 2+ messages in thread
From: Nylon Chen @ 2023-06-13  7:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-riscv, jszhang, conor.dooley, ajones, aou, palmer,
	paul.walmsley, greentime.hu, zong.li, nylon7717, Nylon Chen

Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
---
 arch/riscv/kernel/module.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
index 7c651d55fcbd..f52d8e3d4b63 100644
--- a/arch/riscv/kernel/module.c
+++ b/arch/riscv/kernel/module.c
@@ -310,6 +310,15 @@ static int apply_r_riscv_sub64_rela(struct module *me, u32 *location,
 	return 0;
 }
 
+static int apply_r_riscv_pcrel_32_rela(struct module *me, u32 *location,
+				       Elf_Addr v)
+{
+	ptrdiff_t offset = (void *)v - (void *)location;
+
+	*location = (*location & 0xffff0000) | (offset & 0xffff);
+	return 0;
+}
+
 static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
 				Elf_Addr v) = {
 	[R_RISCV_32]			= apply_r_riscv_32_rela,
@@ -335,6 +344,7 @@ static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
 	[R_RISCV_SUB16]			= apply_r_riscv_sub16_rela,
 	[R_RISCV_SUB32]			= apply_r_riscv_sub32_rela,
 	[R_RISCV_SUB64]			= apply_r_riscv_sub64_rela,
+	[R_RISCV_32_PCREL]		= apply_r_riscv_pcrel_32_rela,
 };
 
 int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
-- 
2.40.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] RISC-V: Support 32_PCREL relocation type in kernel module
  2023-06-13  7:26 [PATCH] RISC-V: Support 32_PCREL relocation type in kernel module Nylon Chen
@ 2023-06-13 16:50 ` Conor Dooley
  0 siblings, 0 replies; 2+ messages in thread
From: Conor Dooley @ 2023-06-13 16:50 UTC (permalink / raw)
  To: Nylon Chen
  Cc: linux-kernel, linux-riscv, jszhang, conor.dooley, ajones, aou,
	palmer, paul.walmsley, greentime.hu, zong.li, nylon7717


[-- Attachment #1.1: Type: text/plain, Size: 225 bytes --]

On Tue, Jun 13, 2023 at 03:26:44PM +0800, Nylon Chen wrote:
> Signed-off-by: Nylon Chen <nylon.chen@sifive.com>

You need to write a commit message chief :/
E.g., explain wasn't this needed before and is now.

Cheers,
Conor.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2023-06-13 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-13  7:26 [PATCH] RISC-V: Support 32_PCREL relocation type in kernel module Nylon Chen
2023-06-13 16:50 ` Conor Dooley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox