From: Siddharth Nayyar <sidnayyar@google.com>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Arnd Bergmann <arnd@arndb.de>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-doc@vger.kernel.org,
Siddharth Nayyar <sidnayyar@google.com>,
gprocida@google.com
Subject: [PATCH v5 3/7] module: populate kflagstab in modpost
Date: Thu, 26 Mar 2026 21:21:31 +0000 [thread overview]
Message-ID: <20260326-kflagstab-v5-3-455cd723dddf@google.com> (raw)
In-Reply-To: <20260326-kflagstab-v5-0-455cd723dddf@google.com>
This patch adds the ability to create entries for kernel symbol flag
bitsets in kflagstab. Modpost populates only the GPL-only flag for now.
Signed-off-by: Siddharth Nayyar <sidnayyar@google.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
---
include/linux/export-internal.h | 7 +++++++
scripts/mod/modpost.c | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/export-internal.h b/include/linux/export-internal.h
index d445705ac13c..4123c7592404 100644
--- a/include/linux/export-internal.h
+++ b/include/linux/export-internal.h
@@ -69,4 +69,11 @@
".long " #crc "\n" \
".previous" "\n")
+#define SYMBOL_FLAGS(sym, flags) \
+ asm(" .section \"___kflagstab+" #sym "\",\"a\"" "\n" \
+ "__flags_" #sym ":" "\n" \
+ " .byte " #flags "\n" \
+ " .previous" "\n" \
+ )
+
#endif /* __LINUX_EXPORT_INTERNAL_H__ */
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0c25b5ad497b..1d721fe67caf 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -244,6 +244,11 @@ static struct symbol *alloc_symbol(const char *name)
return s;
}
+static uint8_t get_symbol_flags(const struct symbol *sym)
+{
+ return sym->is_gpl_only ? KSYM_FLAG_GPL_ONLY : 0;
+}
+
/* For the hash of exported symbols */
static void hash_add_symbol(struct symbol *sym)
{
@@ -1874,6 +1879,9 @@ static void add_exported_symbols(struct buffer *buf, struct module *mod)
buf_printf(buf, "KSYMTAB_%s(%s, \"%s\", \"%s\");\n",
sym->is_func ? "FUNC" : "DATA", sym->name,
sym->is_gpl_only ? "_gpl" : "", sym->namespace);
+
+ buf_printf(buf, "SYMBOL_FLAGS(%s, 0x%02x);\n",
+ sym->name, get_symbol_flags(sym));
}
if (!modversions)
--
2.53.0.1018.g2bb0e51243-goog
next prev parent reply other threads:[~2026-03-26 21:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 21:21 [PATCH v5 0/7] scalable symbol flags with __kflagstab Siddharth Nayyar
2026-03-26 21:21 ` [PATCH v5 1/7] module: define ksym_flags enumeration to represent kernel symbol flags Siddharth Nayyar
2026-03-26 21:21 ` [PATCH v5 2/7] module: add kflagstab section to vmlinux and modules Siddharth Nayyar
2026-03-26 21:21 ` Siddharth Nayyar [this message]
2026-03-26 21:21 ` [PATCH v5 4/7] module: use kflagstab instead of *_gpl sections Siddharth Nayyar
2026-03-26 21:21 ` [PATCH v5 5/7] module: deprecate usage of *_gpl sections in module loader Siddharth Nayyar
2026-03-26 21:21 ` [PATCH v5 6/7] module: remove *_gpl sections from vmlinux and modules Siddharth Nayyar
2026-03-26 21:21 ` [PATCH v5 7/7] documentation: remove references to *_gpl sections Siddharth Nayyar
-- strict thread matches above, loose matches on Subject: below --
2026-03-26 21:25 [PATCH v5 0/7] scalable symbol flags with __kflagstab Siddharth Nayyar
2026-03-26 21:25 ` [PATCH v5 3/7] module: populate kflagstab in modpost Siddharth Nayyar
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=20260326-kflagstab-v5-3-455cd723dddf@google.com \
--to=sidnayyar@google.com \
--cc=arnd@arndb.de \
--cc=atomlin@atomlin.com \
--cc=corbet@lwn.net \
--cc=da.gomez@kernel.org \
--cc=gprocida@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=skhan@linuxfoundation.org \
/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