* [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO()
2025-06-06 4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
@ 2025-06-06 4:10 ` Masahiro Yamada
2025-06-13 10:21 ` Petr Pavlu
2025-06-06 4:10 ` [PATCH 2/4] kbuild: always create intermediate vmlinux.unstripped Masahiro Yamada
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2025-06-06 4:10 UTC (permalink / raw)
To: linux-kbuild
Cc: Petr Pavlu, Alexey Gladkov, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel, Masahiro Yamada
The symbol names in the .modinfo section are never used and already
randomized by the __UNIQUE_ID() macro.
Therefore, the second parameter of __MODULE_INFO() is meaningless
and can be removed to simplify the code.
With this change, the symbol names in the .modinfo section will be
prefixed with __UNIQUE_ID_modinfo, making it clearer that they
originate from MODULE_INFO().
[Before]
$ objcopy -j .modinfo vmlinux.o modinfo.o
$ nm -n modinfo.o | head -n10
0000000000000000 r __UNIQUE_ID_license560
0000000000000011 r __UNIQUE_ID_file559
0000000000000030 r __UNIQUE_ID_description558
0000000000000074 r __UNIQUE_ID_license580
000000000000008e r __UNIQUE_ID_file579
00000000000000bd r __UNIQUE_ID_description578
00000000000000e6 r __UNIQUE_ID_license581
00000000000000ff r __UNIQUE_ID_file580
0000000000000134 r __UNIQUE_ID_description579
0000000000000179 r __UNIQUE_ID_uncore_no_discover578
[After]
$ objcopy -j .modinfo vmlinux.o modinfo.o
$ nm -n modinfo.o | head -n10
0000000000000000 r __UNIQUE_ID_modinfo560
0000000000000011 r __UNIQUE_ID_modinfo559
0000000000000030 r __UNIQUE_ID_modinfo558
0000000000000074 r __UNIQUE_ID_modinfo580
000000000000008e r __UNIQUE_ID_modinfo579
00000000000000bd r __UNIQUE_ID_modinfo578
00000000000000e6 r __UNIQUE_ID_modinfo581
00000000000000ff r __UNIQUE_ID_modinfo580
0000000000000134 r __UNIQUE_ID_modinfo579
0000000000000179 r __UNIQUE_ID_modinfo578
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
include/crypto/algapi.h | 4 ++--
include/linux/module.h | 3 ---
include/linux/moduleparam.h | 9 +++++----
include/net/tcp.h | 4 ++--
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 6e07bbc04089..f5e7454758bd 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -43,8 +43,8 @@
* alias.
*/
#define MODULE_ALIAS_CRYPTO(name) \
- __MODULE_INFO(alias, alias_userspace, name); \
- __MODULE_INFO(alias, alias_crypto, "crypto-" name)
+ MODULE_INFO(alias, name); \
+ MODULE_INFO(alias, "crypto-" name)
struct crypto_aead;
struct crypto_instance;
diff --git a/include/linux/module.h b/include/linux/module.h
index 92e1420fccdf..81b41cc6a19e 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -164,9 +164,6 @@ extern void cleanup_module(void);
struct module_kobject *lookup_or_create_module_kobject(const char *name);
-/* Generic info of form tag = "info" */
-#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
-
/* For userspace: you can also call me... */
#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index bfb85fd13e1f..00166f747e27 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -20,18 +20,19 @@
/* Chosen so that structs with an unsigned long line up. */
#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
-#define __MODULE_INFO(tag, name, info) \
- static const char __UNIQUE_ID(name)[] \
+/* Generic info of form tag = "info" */
+#define MODULE_INFO(tag, info) \
+ static const char __UNIQUE_ID(modinfo)[] \
__used __section(".modinfo") __aligned(1) \
= __MODULE_INFO_PREFIX __stringify(tag) "=" info
#define __MODULE_PARM_TYPE(name, _type) \
- __MODULE_INFO(parmtype, name##type, #name ":" _type)
+ MODULE_INFO(parmtype, #name ":" _type)
/* One for each parameter, describing how to use it. Some files do
multiple of these per line, so can't just use MODULE_INFO. */
#define MODULE_PARM_DESC(_parm, desc) \
- __MODULE_INFO(parm, _parm, #_parm ":" desc)
+ MODULE_INFO(parm, #_parm ":" desc)
struct kernel_param;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 4450c384ef17..ac6df59e4eea 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2661,8 +2661,8 @@ void tcp_update_ulp(struct sock *sk, struct proto *p,
void (*write_space)(struct sock *sk));
#define MODULE_ALIAS_TCP_ULP(name) \
- __MODULE_INFO(alias, alias_userspace, name); \
- __MODULE_INFO(alias, alias_tcp_ulp, "tcp-ulp-" name)
+ MODULE_INFO(alias, name); \
+ MODULE_INFO(alias, "tcp-ulp-" name)
#ifdef CONFIG_NET_SOCK_MSG
struct sk_msg;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO()
2025-06-06 4:10 ` [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO() Masahiro Yamada
@ 2025-06-13 10:21 ` Petr Pavlu
0 siblings, 0 replies; 10+ messages in thread
From: Petr Pavlu @ 2025-06-13 10:21 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Alexey Gladkov, Ard Biesheuvel, Nathan Chancellor, Nicolas Schier,
linux-kbuild, linux-kernel
On 6/6/25 6:10 AM, Masahiro Yamada wrote:
> The symbol names in the .modinfo section are never used and already
> randomized by the __UNIQUE_ID() macro.
>
> Therefore, the second parameter of __MODULE_INFO() is meaningless
> and can be removed to simplify the code.
>
> With this change, the symbol names in the .modinfo section will be
> prefixed with __UNIQUE_ID_modinfo, making it clearer that they
> originate from MODULE_INFO().
>
> [Before]
>
> $ objcopy -j .modinfo vmlinux.o modinfo.o
> $ nm -n modinfo.o | head -n10
> 0000000000000000 r __UNIQUE_ID_license560
> 0000000000000011 r __UNIQUE_ID_file559
> 0000000000000030 r __UNIQUE_ID_description558
> 0000000000000074 r __UNIQUE_ID_license580
> 000000000000008e r __UNIQUE_ID_file579
> 00000000000000bd r __UNIQUE_ID_description578
> 00000000000000e6 r __UNIQUE_ID_license581
> 00000000000000ff r __UNIQUE_ID_file580
> 0000000000000134 r __UNIQUE_ID_description579
> 0000000000000179 r __UNIQUE_ID_uncore_no_discover578
>
> [After]
>
> $ objcopy -j .modinfo vmlinux.o modinfo.o
> $ nm -n modinfo.o | head -n10
> 0000000000000000 r __UNIQUE_ID_modinfo560
> 0000000000000011 r __UNIQUE_ID_modinfo559
> 0000000000000030 r __UNIQUE_ID_modinfo558
> 0000000000000074 r __UNIQUE_ID_modinfo580
> 000000000000008e r __UNIQUE_ID_modinfo579
> 00000000000000bd r __UNIQUE_ID_modinfo578
> 00000000000000e6 r __UNIQUE_ID_modinfo581
> 00000000000000ff r __UNIQUE_ID_modinfo580
> 0000000000000134 r __UNIQUE_ID_modinfo579
> 0000000000000179 r __UNIQUE_ID_modinfo578
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> [...]
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 92e1420fccdf..81b41cc6a19e 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -164,9 +164,6 @@ extern void cleanup_module(void);
>
> struct module_kobject *lookup_or_create_module_kobject(const char *name);
>
> -/* Generic info of form tag = "info" */
> -#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
> -
> /* For userspace: you can also call me... */
> #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index bfb85fd13e1f..00166f747e27 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -20,18 +20,19 @@
> /* Chosen so that structs with an unsigned long line up. */
> #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
>
> -#define __MODULE_INFO(tag, name, info) \
> - static const char __UNIQUE_ID(name)[] \
> +/* Generic info of form tag = "info" */
> +#define MODULE_INFO(tag, info) \
> + static const char __UNIQUE_ID(modinfo)[] \
> __used __section(".modinfo") __aligned(1) \
> = __MODULE_INFO_PREFIX __stringify(tag) "=" info
>
One nit is that MODULE_INFO() is now defined in moduleparam.h, even
though it is a general macro for adding module information and not
specifically tied to parameters. I realize it is needed in moduleparam.h
and that the dependency is from module.h to moduleparam.h, not the other
way around. We could potentially keep the MODULE_INFO() (in module.h) ->
__MODULE_INFO() (moduleparam.h) split solely for this, but it is
probably unnecessary.
The overall change looks ok to me.
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/4] kbuild: always create intermediate vmlinux.unstripped
2025-06-06 4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
2025-06-06 4:10 ` [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO() Masahiro Yamada
@ 2025-06-06 4:10 ` Masahiro Yamada
2025-06-06 4:10 ` [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped Masahiro Yamada
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Masahiro Yamada @ 2025-06-06 4:10 UTC (permalink / raw)
To: linux-kbuild
Cc: Petr Pavlu, Alexey Gladkov, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel, Masahiro Yamada
Generate the intermediate vmlinux.unstripped regardless of
CONFIG_ARCH_VMLINUX_NEEDS_RELOCS.
If CONFIG_ARCH_VMLINUX_NEEDS_RELOCS is unset, vmlinux.unstripped and
vmlinux are identiacal.
This simplifies the build rule, and allows to strip more sections
by adding them to remove-section-y.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.vmlinux | 45 ++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index b64862dc6f08..4f2d4c3fb737 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib
targets :=
-ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS
-vmlinux-final := vmlinux.unstripped
-
-quiet_cmd_strip_relocs = RSTRIP $@
- cmd_strip_relocs = $(OBJCOPY) --remove-section='.rel*' --remove-section=!'.rel*.dyn' $< $@
-
-vmlinux: $(vmlinux-final) FORCE
- $(call if_changed,strip_relocs)
-
-targets += vmlinux
-else
-vmlinux-final := vmlinux
-endif
-
%.o: %.c FORCE
$(call if_changed_rule,cc_o_c)
@@ -61,19 +47,19 @@ targets += .builtin-dtbs-list
ifdef CONFIG_GENERIC_BUILTIN_DTB
targets += .builtin-dtbs.S .builtin-dtbs.o
-$(vmlinux-final): .builtin-dtbs.o
+vmlinux.unstripped: .builtin-dtbs.o
endif
-# vmlinux
+# vmlinux.unstripped
# ---------------------------------------------------------------------------
ifdef CONFIG_MODULES
targets += .vmlinux.export.o
-$(vmlinux-final): .vmlinux.export.o
+vmlinux.unstripped: .vmlinux.export.o
endif
ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX
-$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o
+vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o
arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE
$(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@
@@ -86,17 +72,30 @@ cmd_link_vmlinux = \
$< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
-targets += $(vmlinux-final)
-$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+targets += vmlinux.unstripped
+vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+$(call if_changed_dep,link_vmlinux)
ifdef CONFIG_DEBUG_INFO_BTF
-$(vmlinux-final): $(RESOLVE_BTFIDS)
+vmlinux.unstripped: $(RESOLVE_BTFIDS)
endif
ifdef CONFIG_BUILDTIME_TABLE_SORT
-$(vmlinux-final): scripts/sorttable
+vmlinux.unstripped: scripts/sorttable
endif
+# vmlinux
+# ---------------------------------------------------------------------------
+
+remove-section-y :=
+remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*'
+
+quiet_cmd_strip_relocs = OBJCOPY $@
+ cmd_strip_relocs = $(OBJCOPY) $(addprefix --remove-section=,$(remove-section-y)) $< $@
+
+targets += vmlinux
+vmlinux: vmlinux.unstripped FORCE
+ $(call if_changed,strip_relocs)
+
# modules.builtin.ranges
# ---------------------------------------------------------------------------
ifdef CONFIG_BUILTIN_MODULE_RANGES
@@ -110,7 +109,7 @@ modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \
modules.builtin vmlinux.map vmlinux.o.map FORCE
$(call if_changed,modules_builtin_ranges)
-vmlinux.map: $(vmlinux-final)
+vmlinux.map: vmlinux.unstripped
@:
endif
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped
2025-06-06 4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
2025-06-06 4:10 ` [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO() Masahiro Yamada
2025-06-06 4:10 ` [PATCH 2/4] kbuild: always create intermediate vmlinux.unstripped Masahiro Yamada
@ 2025-06-06 4:10 ` Masahiro Yamada
2025-06-06 12:53 ` kernel test robot
2025-06-06 4:10 ` [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Masahiro Yamada
2025-06-08 14:44 ` [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Alexey Gladkov
4 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2025-06-06 4:10 UTC (permalink / raw)
To: linux-kbuild
Cc: Petr Pavlu, Alexey Gladkov, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel, Masahiro Yamada
Keep the .modinfo section during linking, but strip it from the final
vmlinux.
Adjust scripts/mksysmap to exclude modinfo symbols from kallsyms.
This change will allow the next commit to extract the .modinfo section
from the vmlinux.unstripped intermediate.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
include/asm-generic/vmlinux.lds.h | 2 +-
scripts/Makefile.vmlinux | 2 +-
scripts/mksysmap | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 58a635a6d5bd..ce292ae70a93 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -830,6 +830,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
/* Required sections not related to debugging. */
#define ELF_DETAILS \
+ .modinfo : { *(.modinfo) } \
.comment 0 : { *(.comment) } \
.symtab 0 : { *(.symtab) } \
.strtab 0 : { *(.strtab) } \
@@ -1043,7 +1044,6 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
*(.discard.*) \
*(.export_symbol) \
*(.no_trim_symbol) \
- *(.modinfo) \
/* ld.bfd warns about .gnu.version* even when not emitted */ \
*(.gnu.version*) \
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index 4f2d4c3fb737..e2ceeb9e168d 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -86,7 +86,7 @@ endif
# vmlinux
# ---------------------------------------------------------------------------
-remove-section-y :=
+remove-section-y := .modinfo
remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) += '.rel*'
quiet_cmd_strip_relocs = OBJCOPY $@
diff --git a/scripts/mksysmap b/scripts/mksysmap
index 3accbdb269ac..a607a0059d11 100755
--- a/scripts/mksysmap
+++ b/scripts/mksysmap
@@ -79,6 +79,9 @@
/ _SDA_BASE_$/d
/ _SDA2_BASE_$/d
+# MODULE_INFO()
+/ __UNIQUE_ID_modinfo[0-9]*$/d
+
# ---------------------------------------------------------------------------
# Ignored patterns
# (symbols that contain the pattern are ignored)
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped
2025-06-06 4:10 ` [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped Masahiro Yamada
@ 2025-06-06 12:53 ` kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-06-06 12:53 UTC (permalink / raw)
To: Masahiro Yamada, linux-kbuild
Cc: llvm, oe-kbuild-all, Petr Pavlu, Alexey Gladkov, Ard Biesheuvel,
Nathan Chancellor, Nicolas Schier, linux-kernel, Masahiro Yamada
Hi Masahiro,
kernel test robot noticed the following build warnings:
[auto build test WARNING on masahiroy-kbuild/for-next]
[also build test WARNING on masahiroy-kbuild/fixes linus/master v6.15 next-20250606]
[cannot apply to herbert-cryptodev-2.6/master herbert-crypto-2.6/master arnd-asm-generic/master mcgrof/modules-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/module-remove-meaningless-name-parameter-from-__MODULE_INFO/20250606-121255
base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link: https://lore.kernel.org/r/20250606041029.614348-4-masahiroy%40kernel.org
patch subject: [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped
config: s390-randconfig-002-20250606 (https://download.01.org/0day-ci/archive/20250606/202506062053.zbkFBEnJ-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250606/202506062053.zbkFBEnJ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506062053.zbkFBEnJ-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> s390x-linux-ld: .tmp_vmlinux1: warning: allocated section `.modinfo' not in segment
>> s390x-linux-ld: .tmp_vmlinux2: warning: allocated section `.modinfo' not in segment
>> s390x-linux-ld: vmlinux.unstripped: warning: allocated section `.modinfo' not in segment
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
2025-06-06 4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
` (2 preceding siblings ...)
2025-06-06 4:10 ` [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped Masahiro Yamada
@ 2025-06-06 4:10 ` Masahiro Yamada
2025-06-07 0:46 ` kernel test robot
2025-06-11 10:38 ` Alexey Gladkov
2025-06-08 14:44 ` [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Alexey Gladkov
4 siblings, 2 replies; 10+ messages in thread
From: Masahiro Yamada @ 2025-06-06 4:10 UTC (permalink / raw)
To: linux-kbuild
Cc: Petr Pavlu, Alexey Gladkov, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel, Masahiro Yamada
Currently, we assume all the data for modules.builtin.modinfo are
available in vmlinux.o.
This makes it impossible for modpost, which is invoked after vmlinux.o,
to add additional module info.
This commit moves the modules.builtin.modinfo rule after modpost.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.vmlinux | 28 +++++++++++++++++++++++++++-
scripts/Makefile.vmlinux_o | 26 +-------------------------
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index e2ceeb9e168d..45597068f11f 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
PHONY := __default
-__default: vmlinux
+__default:
include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
@@ -96,6 +96,32 @@ targets += vmlinux
vmlinux: vmlinux.unstripped FORCE
$(call if_changed,strip_relocs)
+# modules.builtin.modinfo
+# ---------------------------------------------------------------------------
+
+OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
+
+targets += modules.builtin.modinfo
+modules.builtin.modinfo: vmlinux.unstripped FORCE
+ $(call if_changed,objcopy)
+
+# modules.builtin
+# ---------------------------------------------------------------------------
+
+__default: modules.builtin
+
+# The second line aids cases where multiple modules share the same object.
+
+quiet_cmd_modules_builtin = GEN $@
+ cmd_modules_builtin = \
+ tr '\0' '\n' < $< | \
+ sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
+ tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
+
+targets += modules.builtin
+modules.builtin: modules.builtin.modinfo FORCE
+ $(call if_changed,modules_builtin)
+
# modules.builtin.ranges
# ---------------------------------------------------------------------------
ifdef CONFIG_BUILTIN_MODULE_RANGES
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index b024ffb3e201..23c8751285d7 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
PHONY := __default
-__default: vmlinux.o modules.builtin.modinfo modules.builtin
+__default: vmlinux.o
include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
@@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
targets += vmlinux.o
-# modules.builtin.modinfo
-# ---------------------------------------------------------------------------
-
-OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
-
-targets += modules.builtin.modinfo
-modules.builtin.modinfo: vmlinux.o FORCE
- $(call if_changed,objcopy)
-
-# modules.builtin
-# ---------------------------------------------------------------------------
-
-# The second line aids cases where multiple modules share the same object.
-
-quiet_cmd_modules_builtin = GEN $@
- cmd_modules_builtin = \
- tr '\0' '\n' < $< | \
- sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
- tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
-
-targets += modules.builtin
-modules.builtin: modules.builtin.modinfo FORCE
- $(call if_changed,modules_builtin)
-
# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
2025-06-06 4:10 ` [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Masahiro Yamada
@ 2025-06-07 0:46 ` kernel test robot
2025-06-11 10:38 ` Alexey Gladkov
1 sibling, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-06-07 0:46 UTC (permalink / raw)
To: Masahiro Yamada, linux-kbuild
Cc: oe-kbuild-all, Petr Pavlu, Alexey Gladkov, Ard Biesheuvel,
Nathan Chancellor, Nicolas Schier, linux-kernel, Masahiro Yamada
Hi Masahiro,
kernel test robot noticed the following build errors:
[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on masahiroy-kbuild/fixes linus/master v6.15 next-20250606]
[cannot apply to herbert-cryptodev-2.6/master herbert-crypto-2.6/master arnd-asm-generic/master mcgrof/modules-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/module-remove-meaningless-name-parameter-from-__MODULE_INFO/20250606-121255
base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link: https://lore.kernel.org/r/20250606041029.614348-5-masahiroy%40kernel.org
patch subject: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-buildonly-randconfig-004-20250606 (https://download.01.org/0day-ci/archive/20250606/202506061718.9bJ7PyNy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250606/202506061718.9bJ7PyNy-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202506061718.9bJ7PyNy-lkp@intel.com/
All errors (new ones prefixed by >>):
>> make[4]: *** No rule to make target 'vmlinux', needed by 'arch/x86/boot/compressed/vmlinux.bin'.
make[4]: Target 'arch/x86/boot/compressed/vmlinux' not remade because of errors.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
2025-06-06 4:10 ` [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Masahiro Yamada
2025-06-07 0:46 ` kernel test robot
@ 2025-06-11 10:38 ` Alexey Gladkov
1 sibling, 0 replies; 10+ messages in thread
From: Alexey Gladkov @ 2025-06-11 10:38 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Petr Pavlu, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel
On Fri, Jun 06, 2025 at 01:10:26PM +0900, Masahiro Yamada wrote:
> Currently, we assume all the data for modules.builtin.modinfo are
> available in vmlinux.o.
>
> This makes it impossible for modpost, which is invoked after vmlinux.o,
> to add additional module info.
>
> This commit moves the modules.builtin.modinfo rule after modpost.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> scripts/Makefile.vmlinux | 28 +++++++++++++++++++++++++++-
> scripts/Makefile.vmlinux_o | 26 +-------------------------
> 2 files changed, 28 insertions(+), 26 deletions(-)
>
> diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
> index e2ceeb9e168d..45597068f11f 100644
> --- a/scripts/Makefile.vmlinux
> +++ b/scripts/Makefile.vmlinux
> @@ -1,7 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0-only
>
> PHONY := __default
> -__default: vmlinux
> +__default:
I found the problem. The problem I was talking about earlier [1] is caused
by this hunk. If I revert it, everything will work.
[1] https://lore.kernel.org/all/aEWhwur_W6UwDsx_@example.org/
> include include/config/auto.conf
> include $(srctree)/scripts/Kbuild.include
> @@ -96,6 +96,32 @@ targets += vmlinux
> vmlinux: vmlinux.unstripped FORCE
> $(call if_changed,strip_relocs)
>
> +# modules.builtin.modinfo
> +# ---------------------------------------------------------------------------
> +
> +OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
> +
> +targets += modules.builtin.modinfo
> +modules.builtin.modinfo: vmlinux.unstripped FORCE
> + $(call if_changed,objcopy)
> +
> +# modules.builtin
> +# ---------------------------------------------------------------------------
> +
> +__default: modules.builtin
> +
> +# The second line aids cases where multiple modules share the same object.
> +
> +quiet_cmd_modules_builtin = GEN $@
> + cmd_modules_builtin = \
> + tr '\0' '\n' < $< | \
> + sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
> + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
> +
> +targets += modules.builtin
> +modules.builtin: modules.builtin.modinfo FORCE
> + $(call if_changed,modules_builtin)
> +
> # modules.builtin.ranges
> # ---------------------------------------------------------------------------
> ifdef CONFIG_BUILTIN_MODULE_RANGES
> diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
> index b024ffb3e201..23c8751285d7 100644
> --- a/scripts/Makefile.vmlinux_o
> +++ b/scripts/Makefile.vmlinux_o
> @@ -1,7 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0-only
>
> PHONY := __default
> -__default: vmlinux.o modules.builtin.modinfo modules.builtin
> +__default: vmlinux.o
>
> include include/config/auto.conf
> include $(srctree)/scripts/Kbuild.include
> @@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
>
> targets += vmlinux.o
>
> -# modules.builtin.modinfo
> -# ---------------------------------------------------------------------------
> -
> -OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
> -
> -targets += modules.builtin.modinfo
> -modules.builtin.modinfo: vmlinux.o FORCE
> - $(call if_changed,objcopy)
> -
> -# modules.builtin
> -# ---------------------------------------------------------------------------
> -
> -# The second line aids cases where multiple modules share the same object.
> -
> -quiet_cmd_modules_builtin = GEN $@
> - cmd_modules_builtin = \
> - tr '\0' '\n' < $< | \
> - sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
> - tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
> -
> -targets += modules.builtin
> -modules.builtin: modules.builtin.modinfo FORCE
> - $(call if_changed,modules_builtin)
> -
> # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
> # ---------------------------------------------------------------------------
>
> --
> 2.43.0
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o
2025-06-06 4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
` (3 preceding siblings ...)
2025-06-06 4:10 ` [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Masahiro Yamada
@ 2025-06-08 14:44 ` Alexey Gladkov
4 siblings, 0 replies; 10+ messages in thread
From: Alexey Gladkov @ 2025-06-08 14:44 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Petr Pavlu, Ard Biesheuvel, Nathan Chancellor,
Nicolas Schier, linux-kernel
On Fri, Jun 06, 2025 at 01:10:22PM +0900, Masahiro Yamada wrote:
>
> Currently, modules.builtin.modinfo is generated from vmlinux.o, which
> occurs before modpost. So, we cannot include modpost-processed data
> into modules.builtin.modinfo.
>
> This patch set allows to generate modules.builtin.modinfo from
> vmlinux.unstripped.
>
> I think this patch set will be useful to clean up this:
>
> https://lore.kernel.org/linux-kbuild/cover.1748335606.git.legion@kernel.org/T/#m98813857abf2101bdf67f1b8529a44f5c7f4746d
>
> The original approach generates modules.builtin.modinfo from two files
> and then cancatenates them into a single file.
>
> I prefer generating modules.builtin.modinfo from a single point.
>
> I think 1/4 is a good cleanup regardless of modules.builtin.modinfo
>
>
> Masahiro Yamada (4):
> module: remove meaningless 'name' parameter from __MODULE_INFO()
> kbuild: always create intermediate vmlinux.unstripped
> kbuild: keep .modinfo section in vmlinux.unstripped
> kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
>
> include/asm-generic/vmlinux.lds.h | 2 +-
> include/crypto/algapi.h | 4 +-
> include/linux/module.h | 3 --
> include/linux/moduleparam.h | 9 ++--
> include/net/tcp.h | 4 +-
> scripts/Makefile.vmlinux | 73 +++++++++++++++++++++----------
> scripts/Makefile.vmlinux_o | 26 +----------
> scripts/mksysmap | 3 ++
> 8 files changed, 63 insertions(+), 61 deletions(-)
Hm. It doesn't work for me :(
I haven't been able to figure out what's wrong yet.
make[3]: *** No rule to make target 'vmlinux', needed by 'arch/x86/boot/compressed/../voffset.h'. Stop.
make[2]: *** [arch/x86/boot/Makefile:96: arch/x86/boot/compressed/vmlinux] Error 2
make[1]: *** [arch/x86/Makefile:320: bzImage] Error 2
make: *** [Makefile:248: __sub-make] Error 2
--
Rgrds, legion
^ permalink raw reply [flat|nested] 10+ messages in thread