The patch series 'scalable symbol flags with __kflagstab'
(
https://lore.kernel.org/all/20260326-kflagstab-v5-4-fa0796fe88d9@google.com)
eliminated separate GPL symbol sections representing GPL only symbols.
Therefore, depending on whether the member gpl_syms is present
in struct module, decide whether GPL module symbols are separated or not.
Signed-off-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
---
kernel.c | 13 ++++++++-----
symbols.c | 9 +++++++--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/kernel.c b/kernel.c
index 8781d6a22414..35e6fd61f077 100644
--- a/kernel.c
+++ b/kernel.c
@@ -3634,9 +3634,11 @@ module_init(void)
case KMOD_V2:
MEMBER_OFFSET_INIT(module_num_syms, "module", "num_syms");
MEMBER_OFFSET_INIT(module_list, "module", "list");
- MEMBER_OFFSET_INIT(module_gpl_syms, "module", "gpl_syms");
- MEMBER_OFFSET_INIT(module_num_gpl_syms, "module",
- "num_gpl_syms");
+ if (MEMBER_EXISTS("module", "gpl_syms")) {
+ MEMBER_OFFSET_INIT(module_gpl_syms, "module", "gpl_syms");
+ MEMBER_OFFSET_INIT(module_num_gpl_syms, "module",
+ "num_gpl_syms");
+ }
if (MEMBER_EXISTS("module", "mem")) { /* 6.4 and later */
kt->flags2 |= KMOD_MEMORY; /* MODULE_MEMORY() can be used. */
@@ -3830,8 +3832,9 @@ module_init(void)
nsyms = UINT(modbuf + OFFSET(module_nsyms));
break;
case KMOD_V2:
- nsyms = UINT(modbuf + OFFSET(module_num_syms)) +
- UINT(modbuf + OFFSET(module_num_gpl_syms));
+ nsyms = UINT(modbuf + OFFSET(module_num_syms));
+ if (VALID_MEMBER(module_num_gpl_syms))
+ nsyms += UINT(modbuf + OFFSET(module_num_gpl_syms));
break;
}
diff --git a/symbols.c b/symbols.c
index e6865cabef74..7b00e26ab0cf 100644
--- a/symbols.c
+++ b/symbols.c
@@ -1976,9 +1976,14 @@ store_module_symbols_6_4(ulong total, int mods_installed)
"module buffer", FAULT_ON_ERROR);
syms = ULONG(modbuf + OFFSET(module_syms));
- gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
nsyms = UINT(modbuf + OFFSET(module_num_syms));
- ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ if (VALID_MEMBER(module_gpl_syms)) {
+ gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
+ ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
+ } else {
+ gpl_syms = 0;
+ ngplsyms = 0;
+ }
nksyms = UINT(modbuf + OFFSET(module_num_symtab));
--
2.51.0