]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
module: populate kflagstab in modpost
authorSiddharth Nayyar <sidnayyar@google.com>
Thu, 26 Mar 2026 21:25:04 +0000 (21:25 +0000)
committerSami Tolvanen <samitolvanen@google.com>
Tue, 31 Mar 2026 23:42:52 +0000 (23:42 +0000)
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>
include/linux/export-internal.h
scripts/mod/modpost.c

index d445705ac13c03d5db795e9f354281eecbe5c68f..4123c7592404a3eccfcb91b14a54155793e5102f 100644 (file)
            ".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__ */
index 0c25b5ad497b584c1803c172ce18b8aaccd92282..1d721fe67caf6ea139fcb8651096b8a845cebb7a 100644 (file)
@@ -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)