From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Cc: kernel-dev@igalia.com, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, fsverity@lists.linux.dev,
keyrings@vger.kernel.org, bpf@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org,
netdev@vger.kernel.org, linux-wpan@vger.kernel.org,
lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-sctp@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
bridge@lists.linux.dev, mptcp@lists.linux.dev,
rds-devel@oss.oracle.com, virtualization@lists.linux.dev,
Mauricio Faria de Oliveira <mfo@igalia.com>
Subject: [PATCH RFC v2 12/13] modpost: move addend_*_rel() calls into addend_rel()
Date: Tue, 18 Aug 2026 23:28:11 -0300 [thread overview]
Message-ID: <20260818-sysctl-module-aliases-v2-12-d5a69dae5798@igalia.com> (raw)
In-Reply-To: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com>
Move the arch-based addend_*_rel() calls into addend_rel() to be reused.
Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
---
scripts/mod/modpost.c | 35 +++++++++++++++++++----------------
scripts/mod/modpost.h | 2 ++
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 75374c64b8cc78bb4d01fa4c64254c7d7cd80e8f..d18a87b882a67f06d5f75ee92f4c26dc713d83b8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1296,6 +1296,24 @@ static Elf_Addr addend_mips_rel(uint32_t *location, unsigned int r_type)
return (Elf_Addr)(-1);
}
+Elf_Addr addend_rel(struct elf_info *elf, unsigned int secndx,
+ unsigned int r_type, Elf_Addr r_offset, Elf_Sym *tsym)
+{
+ void *loc = sym_get_data_by_offset(elf, secndx, r_offset);
+
+ switch (elf->hdr->e_machine) {
+ case EM_386:
+ return addend_386_rel(loc, r_type);
+ case EM_ARM:
+ return addend_arm_rel(loc, tsym, r_type);
+ case EM_MIPS:
+ return addend_mips_rel(loc, r_type);
+ }
+
+ fatal("Please add code to calculate addend for this architecture\n");
+ return (Elf_Addr)(-1);
+}
+
#ifndef EM_RISCV
#define EM_RISCV 243
#endif
@@ -1402,27 +1420,12 @@ static void section_rel(struct module *mod, struct elf_info *elf,
Elf_Sym *tsym;
Elf_Addr taddr, r_offset;
unsigned int r_type, r_sym;
- void *loc;
r_offset = TO_NATIVE(rel->r_offset);
get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym);
- loc = sym_get_data_by_offset(elf, fsecndx, r_offset);
tsym = elf->symtab_start + r_sym;
-
- switch (elf->hdr->e_machine) {
- case EM_386:
- taddr = addend_386_rel(loc, r_type);
- break;
- case EM_ARM:
- taddr = addend_arm_rel(loc, tsym, r_type);
- break;
- case EM_MIPS:
- taddr = addend_mips_rel(loc, r_type);
- break;
- default:
- fatal("Please add code to calculate addend for this architecture\n");
- }
+ taddr = addend_rel(elf, fsecndx, r_type, r_offset, tsym);
check_section_mismatch(mod, elf, tsym,
fsecndx, fromsec, r_offset, taddr);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index d5f6d82837d5b4fbd671ff9dab9bbe353442f6cf..a98811552bd2996c31cf73fd3619e6c58bac8a6d 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -222,6 +222,8 @@ const char *get_basename(const char *path);
char *read_text_file(const char *filename);
char *get_line(char **stringp);
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
+Elf_Addr addend_rel(struct elf_info *elf, unsigned int secndx,
+ unsigned int r_type, Elf_Addr r_offset, Elf_Sym *tsym);
void __attribute__((format(printf, 3, 4)))
modpost_log(bool is_error, struct module *mod, const char *fmt, ...);
--
2.47.3
WARNING: multiple messages have this Message-ID (diff)
From: Mauricio Faria de Oliveira <mfo@igalia.com>
To: Kees Cook <kees@kernel.org>,
Joel Granados <joel.granados@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Cc: kernel-dev@igalia.com, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, fsverity@lists.linux.dev,
keyrings@vger.kernel.org, bpf@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org,
netdev@vger.kernel.org, linux-wpan@vger.kernel.org,
lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, linux-sctp@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
bridge@lists.linux.dev, mptcp@lists.linux.dev,
rds-devel@oss.oracle.com, virtualization@lists.linux.dev,
Mauricio Faria de Oliveira <mfo@igalia.com>
Subject: [PATCH RFC v2 12/13] modpost: move addend_*_rel() calls into addend_rel()
Date: Tue, 18 Aug 2026 23:28:11 -0300 [thread overview]
Message-ID: <20260818-sysctl-module-aliases-v2-12-d5a69dae5798@igalia.com> (raw)
In-Reply-To: <20260818-sysctl-module-aliases-v2-0-d5a69dae5798@igalia.com>
Move the arch-based addend_*_rel() calls into addend_rel() to be reused.
Signed-off-by: Mauricio Faria de Oliveira <mfo@igalia.com>
---
scripts/mod/modpost.c | 35 +++++++++++++++++++----------------
scripts/mod/modpost.h | 2 ++
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 75374c64b8cc78bb4d01fa4c64254c7d7cd80e8f..d18a87b882a67f06d5f75ee92f4c26dc713d83b8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1296,6 +1296,24 @@ static Elf_Addr addend_mips_rel(uint32_t *location, unsigned int r_type)
return (Elf_Addr)(-1);
}
+Elf_Addr addend_rel(struct elf_info *elf, unsigned int secndx,
+ unsigned int r_type, Elf_Addr r_offset, Elf_Sym *tsym)
+{
+ void *loc = sym_get_data_by_offset(elf, secndx, r_offset);
+
+ switch (elf->hdr->e_machine) {
+ case EM_386:
+ return addend_386_rel(loc, r_type);
+ case EM_ARM:
+ return addend_arm_rel(loc, tsym, r_type);
+ case EM_MIPS:
+ return addend_mips_rel(loc, r_type);
+ }
+
+ fatal("Please add code to calculate addend for this architecture\n");
+ return (Elf_Addr)(-1);
+}
+
#ifndef EM_RISCV
#define EM_RISCV 243
#endif
@@ -1402,27 +1420,12 @@ static void section_rel(struct module *mod, struct elf_info *elf,
Elf_Sym *tsym;
Elf_Addr taddr, r_offset;
unsigned int r_type, r_sym;
- void *loc;
r_offset = TO_NATIVE(rel->r_offset);
get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym);
- loc = sym_get_data_by_offset(elf, fsecndx, r_offset);
tsym = elf->symtab_start + r_sym;
-
- switch (elf->hdr->e_machine) {
- case EM_386:
- taddr = addend_386_rel(loc, r_type);
- break;
- case EM_ARM:
- taddr = addend_arm_rel(loc, tsym, r_type);
- break;
- case EM_MIPS:
- taddr = addend_mips_rel(loc, r_type);
- break;
- default:
- fatal("Please add code to calculate addend for this architecture\n");
- }
+ taddr = addend_rel(elf, fsecndx, r_type, r_offset, tsym);
check_section_mismatch(mod, elf, tsym,
fsecndx, fromsec, r_offset, taddr);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index d5f6d82837d5b4fbd671ff9dab9bbe353442f6cf..a98811552bd2996c31cf73fd3619e6c58bac8a6d 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -222,6 +222,8 @@ const char *get_basename(const char *path);
char *read_text_file(const char *filename);
char *get_line(char **stringp);
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
+Elf_Addr addend_rel(struct elf_info *elf, unsigned int secndx,
+ unsigned int r_type, Elf_Addr r_offset, Elf_Sym *tsym);
void __attribute__((format(printf, 3, 4)))
modpost_log(bool is_error, struct module *mod, const char *fmt, ...);
--
2.47.3
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-08-19 2:30 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 2:27 [PATCH RFC v2 00/13] sysctl: add module aliases Mauricio Faria de Oliveira
2026-08-19 2:27 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 01/13] keys, pidns, fs/verity, riscv/vector: reorder '#include <linux/sysctl.h>' Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:33 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 02/13] proc: add config option SYSCTL_MODULE_ALIASES Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:37 ` sashiko-bot
2026-08-19 16:24 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 03/13] sysctl, mod_devicetable: add macro MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:40 ` sashiko-bot
2026-08-19 16:26 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 04/13] sysctl: add register_sysctl() wrapper for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:44 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 05/13] sysctl, parport: update register_sysctl() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:44 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 06/13] sysctl, net: add register_net_sysctl{_sz}() wrappers for MODULE_SYSCTL_TABLE Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:40 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 07/13] sysctl, net: update register_net_sysctl{_sz}() callers with template arguments Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:48 ` sashiko-bot
2026-08-19 16:25 ` Mauricio Faria de Oliveira
2026-08-19 2:28 ` [PATCH RFC v2 08/13] sysctl, net: update register_net_sysctl_sz(ARRAY_SIZE(table_tmpl)) " Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:36 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 09/13] sysctl, ipv6: update register_net_sysctl{_sz}() callers " Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:36 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 10/13] sysctl, net: update register_net_sysctl_sz() edge case Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:39 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 11/13] sysctl: unrandomize struct ctl_table.procname Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:38 ` sashiko-bot
2026-08-19 2:28 ` Mauricio Faria de Oliveira [this message]
2026-08-19 2:28 ` [PATCH RFC v2 12/13] modpost: move addend_*_rel() calls into addend_rel() Mauricio Faria de Oliveira
2026-08-19 2:39 ` sashiko-bot
2026-08-19 2:28 ` [PATCH RFC v2 13/13] modpost: handle MODULE_SYSCTL_TABLE symbols Mauricio Faria de Oliveira
2026-08-19 2:28 ` Mauricio Faria de Oliveira
2026-08-19 2:48 ` sashiko-bot
2026-08-19 16:29 ` Mauricio Faria de Oliveira
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=20260818-sysctl-module-aliases-v2-12-d5a69dae5798@igalia.com \
--to=mfo@igalia.com \
--cc=bpf@vger.kernel.org \
--cc=bridge@lists.linux.dev \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fsverity@lists.linux.dev \
--cc=horms@kernel.org \
--cc=joel.granados@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=keyrings@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lvs-devel@vger.kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nsc@kernel.org \
--cc=pabeni@redhat.com \
--cc=rds-devel@oss.oracle.com \
--cc=virtualization@lists.linux.dev \
/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 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.