diff options
| author | Siddharth Nayyar <sidnayyar@google.com> | 2026-03-27 00:25:04 +0300 |
|---|---|---|
| committer | Sami Tolvanen <samitolvanen@google.com> | 2026-04-01 02:42:52 +0300 |
| commit | 16d0e04f546ffba78c74bbfeb57d93147bcaf2c5 (patch) | |
| tree | 1ebf5a5d161301d08a6d609e4abc3f60e581f4fc | |
| parent | 9743311b4535dc76ce81f46303da0f69bfaa5fd6 (diff) | |
| download | linux-16d0e04f546ffba78c74bbfeb57d93147bcaf2c5.tar.xz | |
module: populate kflagstab in modpost
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>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
| -rw-r--r-- | include/linux/export-internal.h | 7 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 8 |
2 files changed, 15 insertions, 0 deletions
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) |
