2021-05-25 10:32:05

by Bixuan Cui

[permalink] [raw]
Subject: [PATCH -next v2] 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")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Bixuan Cui <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
---
Changes from v2:
Put the sect_empty() definition outside of #ifdef CONFIG_SYSFS.

kernel/module.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index decf4601e943..0543b44db81d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -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


2021-05-25 18:45:49

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH -next v2] module: fix build error when CONFIG_SYSFS is disabled

Quoting Bixuan Cui (2021-05-25 03:50:49)
> 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")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Bixuan Cui <[email protected]>
> Signed-off-by: Stephen Boyd <[email protected]>

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

> ---
> Changes from v2:
> Put the sect_empty() definition outside of #ifdef CONFIG_SYSFS.
>
> kernel/module.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index decf4601e943..0543b44db81d 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -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
>

2021-05-26 13:07:47

by Jessica Yu

[permalink] [raw]
Subject: Re: [PATCH -next v2] module: fix build error when CONFIG_SYSFS is disabled

+++ Bixuan Cui [25/05/21 18:50 +0800]:
>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.

>Reported-by: Hulk Robot <[email protected]>
>Signed-off-by: Bixuan Cui <[email protected]>
>Signed-off-by: Stephen Boyd <[email protected]>

Acked-by: Jessica Yu <[email protected]>

2021-05-27 02:22:06

by Bixuan Cui

[permalink] [raw]
Subject: Re: [PATCH -next v2] module: fix build error when CONFIG_SYSFS is disabled



On 2021/5/26 20:09, Jessica Yu wrote:
>> 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