Skip to contentSkip to conversation

module: fix build error when CONFIG_SYSFS is disabled

PATCH In review Bixuan Cui 3 participants 4 messages May 25, 2021 – May 27, 2021

lore
Share & tools
lore

Bixuan Cui

author
#0 lore raw

PATCH v2 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")

---
Changes from v2:
Put the sect_empty() definition outside of #ifdef CONFIG_SYSFS.

 kernel/module.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/module.c +7 -5
index decf4601e943..0543b44db81d 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;
Signature · 1 line
2.17.1
#1 lore raw

Quoting Bixuan Cui (2021-05-25 03:50:49)

Quoted 8 lines

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")

Ok. The SoB chain is wrong but you may have my SoB.

Quoted 40 lines

---
Changes from v2:
Put the sect_empty() definition outside of #ifdef CONFIG_SYSFS.

 kernel/module.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/module.c +7 -6
index decf4601e943..0543b44db81d 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;
--

2.17.1

Acked-by on v2 1/1
#2 lore raw
In reply to Bixuan Cui

+++ Bixuan Cui [25/05/21 18:50 +0800]:

Quoted 5 lines

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")

Hm, can't find this commit in the next-20210526 tree. Commit 7685f91fed25 ("module: add printk formats to add module build ID to stacktraces") seems to be the correct one.

Quoted 3 lines
author
#3 lore raw
Quoted 9 lines · Jessica Yu
Quoted 5 lines

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")

Hm, can't find this commit in the next-20210526 tree. Commit 7685f91fed25 ("module: add printk formats to add module build ID to stacktraces") seems to be the correct one.

It was my linux-next repository that was abnormal. :-( I re-downloaded it and commit id is 7685f91fed25.

Thanks,
Bixuan Cui