From: Stafford Horne <shorne@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Stafford Horne <shorne@gmail.com>,
Jonas Bonn <jonas@southpole.se>,
Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
Eric Biederman <ebiederm@xmission.com>,
Kees Cook <keescook@chromium.org>,
linux-openrisc@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] openrisc: Add support for more module relocations
Date: Wed, 10 Apr 2024 21:51:58 +0100 [thread overview]
Message-ID: <20240410205201.1885032-1-shorne@gmail.com> (raw)
When testing modules in OpenRISC I found R_OR32_AHI16 (signed adjusted
high 16-bit) and R_OR32_SLO16 (split low 16-bit) relocations are used in
modules but not implemented yet.
This patch adds the relocations. Note, we use the old naming R_OR32_*
instead or the new naming R_OR1K_* to avoid change as this header is
exported as a user api.
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
arch/openrisc/include/uapi/asm/elf.h | 2 ++
arch/openrisc/kernel/module.c | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/openrisc/include/uapi/asm/elf.h b/arch/openrisc/include/uapi/asm/elf.h
index 6868f81c281e..0c882a388524 100644
--- a/arch/openrisc/include/uapi/asm/elf.h
+++ b/arch/openrisc/include/uapi/asm/elf.h
@@ -43,6 +43,8 @@
#define R_OR32_JUMPTARG 6
#define R_OR32_VTINHERIT 7
#define R_OR32_VTENTRY 8
+#define R_OR32_AHI16 35
+#define R_OR32_SLO16 39
typedef unsigned long elf_greg_t;
diff --git a/arch/openrisc/kernel/module.c b/arch/openrisc/kernel/module.c
index 532013f523ac..01bda5616114 100644
--- a/arch/openrisc/kernel/module.c
+++ b/arch/openrisc/kernel/module.c
@@ -55,6 +55,16 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
value |= *location & 0xfc000000;
*location = value;
break;
+ case R_OR32_AHI16:
+ /* Adjust the operand to match with a signed LO16. */
+ value += 0x8000;
+ *((uint16_t *)location + 1) = value >> 16;
+ break;
+ case R_OR32_SLO16:
+ /* Split value lower 16-bits. */
+ value = ((value & 0xf800) << 10) | (value & 0x7ff);
+ *location = (*location & ~0x3e007ff) | value;
+ break;
default:
pr_err("module %s: Unknown relocation: %u\n",
me->name, ELF32_R_TYPE(rel[i].r_info));
--
2.44.0
next reply other threads:[~2024-04-10 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 20:51 Stafford Horne [this message]
2024-04-11 12:12 ` [PATCH] openrisc: Add support for more module relocations Geert Uytterhoeven
2024-04-11 15:51 ` Stafford Horne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240410205201.1885032-1-shorne@gmail.com \
--to=shorne@gmail.com \
--cc=ebiederm@xmission.com \
--cc=jonas@southpole.se \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-openrisc@vger.kernel.org \
--cc=stefan.kristiansson@saunalahti.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).