Skip to contentSkip to conversation

module: fix build error when CONFIG_SYSFS is disabled

PATCH Superseded Bixuan Cui 2 participants 4 messages May 25, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bixuan Cui

author
#0 lore raw

PATCH 1/1 module: fix build error when CONFIG_SYSFS is disabled

Fix build error when disable CONFIG_SYSFS:
kernel/module.c:2805:8: error: implicit declaration of function ‘sect_empty’; did you mean ‘desc_empty’? [-Werror=implicit-function-declaration]
2805 | if (!sect_empty(sechdr) && sechdr->sh_type == SHT_NOTE &&

Fixes 9ee6682aa528 ("module: add printk formats to add module build ID to stacktraces")
---
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +2 -1
index decf4601e943..7287ecc76714 100644
@@ -2794,7 +2794,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
 }
 #endif /* CONFIG_KALLSYMS */
 
-#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
+#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) && \
+	IS_ENABLED(CONFIG_SYSFS)
 static void init_build_id(struct module *mod, const struct load_info *info)
 {
 	const Elf_Shdr *sechdr;
Signature · 1 line
2.17.1
#1 lore raw

Quoting Bixuan Cui (2021-05-25 01:54:00)

Quoted 8 lines
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +0 -0
index decf4601e943..7287ecc76714 100644

kernel/module.c static void add_kallsyms(struct module *mod, const struct load_info *info) · line 2798

Quoted 6 lines
kernel/module.c +2 -1
@@ -2794,7 +2794,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
 }
 #endif /* CONFIG_KALLSYMS */
 
-#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
+#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) && \
+       IS_ENABLED(CONFIG_SYSFS)

Thanks for the report. It is the wrong fix though as we don't care that sysfs is enabled or not. How about this patch?

---8<---

kernel/module.c +7 -5
index b5dd92e35b02..5be1f8ea4886 100644
@@ -1462,6 +1462,13 @@ resolve_symbol_wait(struct module *mod,
 	return ksym;
 }
 
+#ifdef CONFIG_KALLSYMS
+static inline bool sect_empty(const Elf_Shdr *sect)
+{
+	return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
+}
+#endif
+
 /*
  * /sys/module/foo/sections stuff
  * J. Corbet <[email protected]>
@@ -1469,11 +1476,6 @@ resolve_symbol_wait(struct module *mod,
 #ifdef CONFIG_SYSFS
 
 #ifdef CONFIG_KALLSYMS
-static inline bool sect_empty(const Elf_Shdr *sect)
-{
-	return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
-}
-
 struct module_sect_attr {
 	struct bin_attribute battr;
 	unsigned long address;
author
#2 lore raw
Quoted 12 lines · Stephen Boyd

Quoting Bixuan Cui (2021-05-25 01:54:00)

Quoted 11 lines
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +0 -0
index decf4601e943..7287ecc76714 100644
@@ -2794,7 +2794,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
 }
 #endif /* CONFIG_KALLSYMS */
 
Quoted 5 lines

kernel/module.c static void add_kallsyms(struct module *mod, const struct load_info *info) · line 2798

Quoted 3 lines
kernel/module.c +2 -1
-#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
+#if IS_ENABLED(CONFIG_KALLSYMS) && IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) && \
+       IS_ENABLED(CONFIG_SYSFS)

Thanks for the report. It is the wrong fix though as we don't care that sysfs is enabled or not. How about this patch?

Hello, your patch solves that problem very well. Will you send a new patch?

Thanks
Bixuan Cui