From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7482F3C3D; Thu, 18 Sep 2025 08:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182820; cv=none; b=G5JHmFaZFLDZRPw+eyXeg0EUy87eXUUBKU9zPLR+t+IQ3Lua1Xpx+PxfEHsVI2BgzFuPLzc0dQGO3fOrENnS/6Z8wnZmvdkQ+on0iYuT18shy99r3/GJgQWSMvqtSadju7TefEdgUUHw5alRYtTy3sEC1G4b8+Pw9rzr+IGLaZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182820; c=relaxed/simple; bh=d4f0cPYdTF+9RjWHiMGJtE229ZsE/AIhHwl1ldYrtbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K7rKRoxgWRgpI4loPy5fxw/0IB1+klIBn3G5s24GUM8NV08488YOKPR1a/tLa1jafE/NyNE9u5IEbM/2Bd9f4zXOvNfVMI8JxVep8tAAMsXlrIKQIonFBD8VAHTGp3oEFGGwljx6WAdwKv2LWNvH3jhFc39+lcOGtDI7gt576tQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f6OYvoxL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f6OYvoxL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C7AC4CEF7; Thu, 18 Sep 2025 08:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182819; bh=d4f0cPYdTF+9RjWHiMGJtE229ZsE/AIhHwl1ldYrtbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f6OYvoxLO7Um33DAN3cK3Lg6PPqS6u035GYnbXK+QX6032X+G2+3DpKC+cWNSiE7T fNbl4ZBV+enhynfuxxMVCGcO4O4Nt4NPiQwzA0MnXrNTfETc4i+8cbba0eZwxvR58e ZHOJtOSGJbASyyPgpOK3MwEGaU6B0i2nPOoqjD8BVAYVnn3Bk2Xm9qgnaYOGFKxV5b qcaVoAA+VOyjugwcAOmgE8EyCq8p24Be2f2qNAbalixwzv57XHM0BRW4qMcJyeQewp tES4jY/ztS2uStk96Ys8YmMUfzP0yba2KFjpk8sDIxqhLAfYW1TQdwHUFklp0VzrjS EQdQ8hXVBRo7A== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-s390@vger.kernel.org, kernel test robot Subject: [PATCH v8 1/8] s390: vmlinux.lds.S: Reorder sections Date: Thu, 18 Sep 2025 10:05:45 +0200 Message-ID: <20d40a7a3a053ba06a54155e777dcde7fdada1db.1758182101.git.legion@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the upcoming changes, the ELF_DETAILS macro will be extended with the ".modinfo" section, which will cause an error: >> 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 This happens because the .vmlinux.info use :NONE to override the default segment and tell the linker to not put the section in any segment at all. To avoid this, we need to change the sections order that will be placed in the default segment. Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Alexander Gordeev Cc: linux-s390@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202506062053.zbkFBEnJ-lkp@int= el.com/ Signed-off-by: Alexey Gladkov Acked-by: Heiko Carstens --- arch/s390/kernel/vmlinux.lds.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 1c606dfa595d8..feecf1a6ddb44 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -209,6 +209,11 @@ SECTIONS . =3D ALIGN(PAGE_SIZE); _end =3D . ; =20 + /* Debugging sections. */ + STABS_DEBUG + DWARF_DEBUG + ELF_DETAILS + /* * uncompressed image info used by the decompressor * it should match struct vmlinux_info @@ -239,11 +244,6 @@ SECTIONS #endif } :NONE =20 - /* Debugging sections. */ - STABS_DEBUG - DWARF_DEBUG - ELF_DETAILS - /* * Make sure that the .got.plt is either completely empty or it * contains only the three reserved double words. --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1871D2F2613; Thu, 18 Sep 2025 08:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182823; cv=none; b=d+49aus5poH7VLFv7IbCsQftBBFD2Obk+d4cOCvPVCVCLr/KEjD1ZGZ9vzUEJtWWCSS/UJj8EiFDB04jPLnV7c8PLrXGWmW6ZYkHrQv2mkFRuNOu6R7Cvx4OqYyYzFxk/xXjMyaXavIOYv/PtccE1asJb2a8W4i92QOKg5ruzAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182823; c=relaxed/simple; bh=bb5ubgK/wnhVsZbyUpoKbh+1vpm6J0XlrHxcoyqPAfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yl7pg4UVK0j16QkhNWx1EDq6W/LeeamzsMQY6RD84g7ji4JzMhXcXxaeVbQRdFbMiY69AxNMENgHPLItT9O0PgXa1WU7UydQHxR9KWySotZG3zgehQaYcURtgAhGBa1UAR4QJCE/kLnX9twTaezWQVueiOfpeEV6dpAkjgzY0RE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p8Sfdiut; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p8Sfdiut" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47107C4CEFE; Thu, 18 Sep 2025 08:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182822; bh=bb5ubgK/wnhVsZbyUpoKbh+1vpm6J0XlrHxcoyqPAfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8SfdiutRi1dNuJaSQDjHvZp2AvAuH3VejsqkAPNU18abPlavYQHq3zelfSQsE1VP sCEYQ7eKxiF/VUtXSIF6qvPXcQtNVFD2HFugj3oK0uF8tBnpBtnNPmjdu02klchked li2tJNnsNygtsQ4XupA23BdbOnHsFgsPozubJW8VwT6qUbWcpLElOomcwuJLGi4d4k tyNg6NYoU/+0oTPODJVsM1Vaa72fGKmYE5OnkhldzO2wx9StOhMFw8hSLIfccNnHyU 5lvKcf9Fac9ArnJEjMGMoHfQ5ExZVjig5XjvIwFLkc8u0IbZw6wAQ0PAmceoZGtyxM oaOrCXrqtt5JQ== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Masahiro Yamada , Nicolas Schier Subject: [PATCH v8 2/8] kbuild: always create intermediate vmlinux.unstripped Date: Thu, 18 Sep 2025 10:05:46 +0200 Message-ID: X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: 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 Reviewed-by: Nicolas Schier --- scripts/Makefile.vmlinux | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index b64862dc6f08d..4f2d4c3fb7372 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -9,20 +9,6 @@ include $(srctree)/scripts/Makefile.lib =20 targets :=3D =20 -ifdef CONFIG_ARCH_VMLINUX_NEEDS_RELOCS -vmlinux-final :=3D vmlinux.unstripped - -quiet_cmd_strip_relocs =3D RSTRIP $@ - cmd_strip_relocs =3D $(OBJCOPY) --remove-section=3D'.rel*' --remove-= section=3D!'.rel*.dyn' $< $@ - -vmlinux: $(vmlinux-final) FORCE - $(call if_changed,strip_relocs) - -targets +=3D vmlinux -else -vmlinux-final :=3D vmlinux -endif - %.o: %.c FORCE $(call if_changed_rule,cc_o_c) =20 @@ -61,19 +47,19 @@ targets +=3D .builtin-dtbs-list =20 ifdef CONFIG_GENERIC_BUILTIN_DTB targets +=3D .builtin-dtbs.S .builtin-dtbs.o -$(vmlinux-final): .builtin-dtbs.o +vmlinux.unstripped: .builtin-dtbs.o endif =20 -# vmlinux +# vmlinux.unstripped # ------------------------------------------------------------------------= --- =20 ifdef CONFIG_MODULES targets +=3D .vmlinux.export.o -$(vmlinux-final): .vmlinux.export.o +vmlinux.unstripped: .vmlinux.export.o endif =20 ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX -$(vmlinux-final): arch/$(SRCARCH)/tools/vmlinux.arch.o +vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o =20 arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE $(Q)$(MAKE) $(build)=3Darch/$(SRCARCH)/tools $@ @@ -86,17 +72,30 @@ cmd_link_vmlinux =3D \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -targets +=3D $(vmlinux-final) -$(vmlinux-final): scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +targets +=3D 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 =20 ifdef CONFIG_BUILDTIME_TABLE_SORT -$(vmlinux-final): scripts/sorttable +vmlinux.unstripped: scripts/sorttable endif =20 +# vmlinux +# ------------------------------------------------------------------------= --- + +remove-section-y :=3D +remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' + +quiet_cmd_strip_relocs =3D OBJCOPY $@ + cmd_strip_relocs =3D $(OBJCOPY) $(addprefix --remove-section=3D,$(re= move-section-y)) $< $@ + +targets +=3D 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_bui= ltin_ranges.awk \ modules.builtin vmlinux.map vmlinux.o.map FORCE $(call if_changed,modules_builtin_ranges) =20 -vmlinux.map: $(vmlinux-final) +vmlinux.map: vmlinux.unstripped @: =20 endif --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A47932F7AC3; Thu, 18 Sep 2025 08:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182825; cv=none; b=LWcs6SDynvuuC5rskqcHy9O6a+HAQPmQHOzvavr+Mr7gcxkN+09fsi0EeYBuqq6fuaNZC+yKgqKQTN8zspASnc6XWvzgkzIebURUQeHtMY5llv2DGwx1goHAv/aqrGcRGh7CXU1mT3JZI6GFHqc/3ORfHsHkKBGHOhpCCvUuSCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182825; c=relaxed/simple; bh=iQ5SvAco/8JTZzvo/2fbFxIJ4aopT9Kas690js7coTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H0XdPJlKXhHZ8Jw+r4O7XKaBmzemJTFtjncs1Nzm2rhyGvYGb9wj/3eD0AsfopZRytG8LceFAi9ssmXZTxGYwoNR8FDnkJ1dUlAnAghWfubdhKfAgUk/YnJFEFBh07a31EBOeoLRMyMBJTfWJWNFrMlWwtQjT2+ObKul280Q+QQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CRFYP+la; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CRFYP+la" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 115E6C4CEF1; Thu, 18 Sep 2025 08:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182825; bh=iQ5SvAco/8JTZzvo/2fbFxIJ4aopT9Kas690js7coTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CRFYP+laXm+hRkqcwWYAZBg5bBQb+830CDoZz3SQBddinCX60j431EXo97WegxZ6+ 9Rr/PhiIT0TxzL0qqH2hHpPqNJIvjyZs1BUdISxsq6BJolaPxjhQRQOLBj9nBr4Po5 ZvEjNk/azg9CBX3oZ31CHYwgWEvQjLZwFcpygJ5mk9Wwmm5Tj0z/eSbKGmBcTPQFBl a75RHIYpbEo6PeIudqwF/FuV8whW3bGniLa9ShTFmLiiKDjABZE8TJuSxWWPsed4RD qudn6G9sSgvqTUJ6TGj0R2/aPFD7B1NZd1LFded7BXo/8TyhXmZumeQHL8hmFw/5AZ T4prlZ+8J2dfA== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Masahiro Yamada , Alexey Gladkov Subject: [PATCH v8 3/8] kbuild: keep .modinfo section in vmlinux.unstripped Date: Thu, 18 Sep 2025 10:05:47 +0200 Message-ID: X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: 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 Signed-off-by: Alexey Gladkov Reviewed-by: Nicolas Schier --- include/asm-generic/vmlinux.lds.h | 2 +- scripts/Makefile.vmlinux | 7 +++++-- scripts/mksysmap | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index ae2d2359b79e9..cfa63860dfd4c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -831,6 +831,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) =20 /* Required sections not related to debugging. */ #define ELF_DETAILS \ + .modinfo : { *(.modinfo) } \ .comment 0 : { *(.comment) } \ .symtab 0 : { *(.symtab) } \ .strtab 0 : { *(.strtab) } \ @@ -1044,7 +1045,6 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPE= LLER_CLANG) *(.discard.*) \ *(.export_symbol) \ *(.no_trim_symbol) \ - *(.modinfo) \ /* ld.bfd warns about .gnu.version* even when not emitted */ \ *(.gnu.version*) \ =20 diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 4f2d4c3fb7372..70856dab0f541 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -86,11 +86,14 @@ endif # vmlinux # ------------------------------------------------------------------------= --- =20 -remove-section-y :=3D +remove-section-y :=3D .modinfo remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' =20 +# To avoid warnings: "empty loadable segment detected at ..." from GNU obj= copy, +# it is necessary to remove the PT_LOAD flag from the segment. quiet_cmd_strip_relocs =3D OBJCOPY $@ - cmd_strip_relocs =3D $(OBJCOPY) $(addprefix --remove-section=3D,$(re= move-section-y)) $< $@ + cmd_strip_relocs =3D $(OBJCOPY) $(patsubst %,--set-section-flags %= =3Dnoload,$(remove-section-y)) $< $@; \ + $(OBJCOPY) $(addprefix --remove-section=3D,$(remo= ve-section-y)) $@ =20 targets +=3D vmlinux vmlinux: vmlinux.unstripped FORCE diff --git a/scripts/mksysmap b/scripts/mksysmap index 3accbdb269ac7..a607a0059d119 100755 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -79,6 +79,9 @@ / _SDA_BASE_$/d / _SDA2_BASE_$/d =20 +# MODULE_INFO() +/ __UNIQUE_ID_modinfo[0-9]*$/d + # ------------------------------------------------------------------------= --- # Ignored patterns # (symbols that contain the pattern are ignored) --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 822072F9C29; Thu, 18 Sep 2025 08:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182828; cv=none; b=amu0YmcmMhmF4o0Mgghr7bMV8ms2rdJGARb0mvmQGRDbuy1CFURnmgAxcj8aNYsSaPfGxet8NAvTTXl+he2/nPnQbKOUsrbceZTB3CtGNuzlHPoa+VhVLvO/H83Bppb3qrZm1gMMNXDPOxe/StkO1oC3AiStck+tCoAPFJaV1tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182828; c=relaxed/simple; bh=zMV7paovTklqA34lQ9CJzq3IRF7CgMDZ2aa/9ZrTKEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jC4M4LPLIIFSoPDQr7VzKvVdhDHYS6X3XTYCnppkmGoXL5Hc2vaiFpbfgTIwSwUHT505TaAQEA6X1NKk4VlUFBTf9ZBJKmSe0lgLxFS0PR8wAGek1KYs9/a48pOOUbwBi2sX3YAdpmzr8dtGSCJGuIsQbVn9mPdJRgn1v1C9EWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tv3QIub6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tv3QIub6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF622C4CEE7; Thu, 18 Sep 2025 08:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182828; bh=zMV7paovTklqA34lQ9CJzq3IRF7CgMDZ2aa/9ZrTKEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tv3QIub6SuL0CIIMCfOajcP0mCJjvu+105WzjuR0CllwGtW0wgYmE+vMHIf3jmWU8 NiyJSWKJ+iIQw4qvWm0f3aMuKs4uXc/akGhFiwkOxeUzq49+IS5VTHTXsqcSaWpuGR vVG0Bb/GhNgVKDI1Hoi6+m9wrtd8dXLGVG+QC13ksphntCYV35Ysw9jx+Ss3kp2Qyr 9w3WHGPzSf1Mx9tQAoUXRE1djm5p/etZyoQsQn8suYc1n9PfedutamLyelGZvTx+jH K3frBCtfEPm+CcgBDsY+3HCv5G/XoOZ7LawXG+6j7R7w2dampEkmKR3kmJ669+xre9 wtPawQ4Y0YwMA== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Masahiro Yamada , Alexey Gladkov , Nicolas Schier Subject: [PATCH v8 4/8] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Date: Thu, 18 Sep 2025 10:05:48 +0200 Message-ID: X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: 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 Signed-off-by: Alexey Gladkov Reviewed-by: Nicolas Schier --- scripts/Makefile.vmlinux | 26 ++++++++++++++++++++++++++ scripts/Makefile.vmlinux_o | 26 +------------------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 70856dab0f541..ce79461714979 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -99,6 +99,32 @@ targets +=3D vmlinux vmlinux: vmlinux.unstripped FORCE $(call if_changed,strip_relocs) =20 +# modules.builtin.modinfo +# ------------------------------------------------------------------------= --- + +OBJCOPYFLAGS_modules.builtin.modinfo :=3D -j .modinfo -O binary + +targets +=3D 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 =3D GEN $@ + cmd_modules_builtin =3D \ + tr '\0' '\n' < $< | \ + sed -n 's/^[[:alnum:]:_]*\.file=3D//p' | \ + tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ + +targets +=3D 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 b024ffb3e2018..23c8751285d79 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only =20 PHONY :=3D __default -__default: vmlinux.o modules.builtin.modinfo modules.builtin +__default: vmlinux.o =20 include include/config/auto.conf include $(srctree)/scripts/Kbuild.include @@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_L= IBS) FORCE =20 targets +=3D vmlinux.o =20 -# modules.builtin.modinfo -# ------------------------------------------------------------------------= --- - -OBJCOPYFLAGS_modules.builtin.modinfo :=3D -j .modinfo -O binary - -targets +=3D 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 =3D GEN $@ - cmd_modules_builtin =3D \ - tr '\0' '\n' < $< | \ - sed -n 's/^[[:alnum:]:_]*\.file=3D//p' | \ - tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@ - -targets +=3D 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 rebu= ilt. # ------------------------------------------------------------------------= --- =20 --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B3BC2FBDE0; Thu, 18 Sep 2025 08:07:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182832; cv=none; b=OIRryJbIVyaBsmhGpdTKuTdInKTN2AZNcrr21xSF4Fpi5IIFAruLXmHu6cgEyPchn3Q5rlmHo6pJ/L9UKXX9u6dL5VzMd4Ptzuy4BceUUbACaD5P8s6XwrYe2oWfGPmkjGQB5BJh74hq5DyZkknhFJ0twGgUDC8UtF6oBcSLHWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182832; c=relaxed/simple; bh=XBWJaxmtBirrXj8wv9G7xuKZMzhfTcfINGcpYJ1NhCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSlD3gyWPXyF7BsTht0fZ8lo4vC+zw+YC730Tf4I2siyP7fT0N7yT+sGigcIcYeaCbo/F0QdDlmTTBwRXyDm76p/ZJUyQIo9PNDu3dWKcbS7ZUCfPx7p47tpQ9nc1B17Zc0XMP4wbGFlxXu2b3wIua2PgLRfE/zr8TmdBkZcSWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kABUX8p8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kABUX8p8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D28F5C4CEF0; Thu, 18 Sep 2025 08:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182832; bh=XBWJaxmtBirrXj8wv9G7xuKZMzhfTcfINGcpYJ1NhCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kABUX8p8dFSCjVuNXWjogazoqPzMU8S2jGvFrlVOwSG0FxAoZbVf9kIicNYPH8b1J m7dYaNL3r0rxtgyZqZVDXQozgA/iTS1P+ONRSBzAiW3yXxSE/PKdYP2mszcfllnmE1 l/70ScsDSHqKr6r/lg3mQe+EvzjZt8YoTIj3Eyutp9NVXdpElj5RPJHl5VW9PYpcNf n6kl5+K3PvQmAF1gEQgca9KKk8DFnzblHkB8/Y/Q5XsB/Oss0I5P5DZ0H2Rkn3Uc1q OlEK84bE/0nKFen9h7TbhM3XanxfTy8Q/i7IL7DxiK2esAwaf/rqNo/0Z50Eoo10aM 6R/qGgwxiEsag== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Khalid Aziz , "Martin K. Petersen" , linux-scsi@vger.kernel.org, James Bottomley , Arnd Bergmann , Damien Le Moal Subject: [PATCH v8 5/8] scsi: Always define blogic_pci_tbl structure Date: Thu, 18 Sep 2025 10:05:49 +0200 Message-ID: X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The blogic_pci_tbl structure is used by the MODULE_DEVICE_TABLE macro. There is no longer a need to protect it with the MODULE condition, since this no longer causes the compiler to warn about an unused variable. To avoid warnings when -Wunused-const-variable option is used, mark it as __maybe_unused for such configuration. Cc: Khalid Aziz Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Suggested-by: James Bottomley Signed-off-by: Alexey Gladkov Signed-off-by: Arnd Bergmann Reviewed-by: Damien Le Moal --- drivers/scsi/BusLogic.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 1f100270cd385..82597bd96525b 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -3715,7 +3715,6 @@ static void __exit blogic_exit(void) =20 __setup("BusLogic=3D", blogic_setup); =20 -#ifdef MODULE /*static const struct pci_device_id blogic_pci_tbl[] =3D { { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -3725,13 +3724,12 @@ __setup("BusLogic=3D", blogic_setup); PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { } };*/ -static const struct pci_device_id blogic_pci_tbl[] =3D { +static const struct pci_device_id blogic_pci_tbl[] __maybe_unused =3D { {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER)}, {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC= )}, {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, {0, }, }; -#endif MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); =20 module_init(blogic_init); --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E79D2FC009; Thu, 18 Sep 2025 08:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182838; cv=none; b=h3yRL7O+fc1tl3YPBS8x+i1vWVQirt0FmmOrIPy0CUY/IY+pAivxWDKicY++EgAv2UwyoeYoydRplAI+QdsJVsiZ0rTE/pcc5AlwsJMzPEE3jz0s3VwCtydNzweJLtc0NYnI9QBpMlf/oVNRXJ8eC3UxxGusEtbRz+PvReCeeBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182838; c=relaxed/simple; bh=kC7c43KrE4fGCEO5PzpbSWjdJjCEcmcV83f70KvxQs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DMl95gmnIdtFiwIQnspaZRN2GfWBEHtkYrYWqfFpZ7tB5griR70/6mOyseN3OqHlN7KsCDP+Ny6ndmNLbPg5ksJ0fOzycEwBdSMoR8vA3ouQMj1PA2Hlk6QyCF+df4ZbpyolU80+GnGZishphqg3hsG1vfoHNc0RIJUhQw+AZYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DWyibfNs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DWyibfNs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C16EC4CEE7; Thu, 18 Sep 2025 08:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182835; bh=kC7c43KrE4fGCEO5PzpbSWjdJjCEcmcV83f70KvxQs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DWyibfNsCDAe9YU6h/fHgAIKcWQ0txcGWWmj/0q1CEcYz7qPoAwwyMwh6nlimU87s tMDWjQnkfBJJhb3xhUsQiE1JP1dcuRp9O1XA/h9yLFi9dpjkAn6kBhdBX7BA8KafMe jNc7dCnkDAtTwlWdlycJmdAcN8FTcLr2f7GDDVZSKbLHjeSh9zE83rgJa9TCEaQtOp DidZ9AUSEYxEz5R9K2S2Wq9DBWDDT5HIYgvKSsj+VUf4eSb9E8B3rXr5Y79W1/w/v3 YkFeyveemzY268oDRW6cbehVNg9LDGLWBL6E4UrEV5xVa9YB4japykZbXn9FjYmI0T AFhSG6OQ/nnUw== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Miguel Ojeda , Andreas Hindborg , Danilo Krummrich , Alex Gaynor , rust-for-linux@vger.kernel.org Subject: [PATCH v8 6/8] modpost: Add modname to mod_device_table alias Date: Thu, 18 Sep 2025 10:05:50 +0200 Message-ID: <1a0d0bd87a4981d465b9ed21e14f4e78eaa03ded.1758182101.git.legion@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At this point, if a symbol is compiled as part of the kernel, information about which module the symbol belongs to is lost. To save this it is possible to add the module name to the alias name. It's not very pretty, but it's possible for now. Cc: Miguel Ojeda Cc: Andreas Hindborg Cc: Danilo Krummrich Cc: Alex Gaynor Cc: rust-for-linux@vger.kernel.org Signed-off-by: Alexey Gladkov Acked-by: Danilo Krummrich Acked-by: Nicolas Schier --- include/linux/module.h | 14 +++++++++++++- rust/kernel/device_id.rs | 8 ++++---- scripts/mod/file2alias.c | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 3319a5269d286..e31ee29fac6b7 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -244,10 +244,22 @@ struct module_kobject *lookup_or_create_module_kobjec= t(const char *name); /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _descrip= tion) =20 +/* + * Format: __mod_device_table__kmod_____ + * Parts of the string `__kmod_` and `__` are used as delimiters when pars= ing + * a symbol in file2alias.c + */ +#define __mod_device_table(type, name) \ + __PASTE(__mod_device_table__, \ + __PASTE(__KBUILD_MODNAME, \ + __PASTE(__, \ + __PASTE(type, \ + __PASTE(__, name))))) + #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ -static typeof(name) __mod_device_table__##type##__##name \ +static typeof(name) __mod_device_table(type, name) \ __attribute__ ((used, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs index 70d57814ff79b..62c42da12e9de 100644 --- a/rust/kernel/device_id.rs +++ b/rust/kernel/device_id.rs @@ -195,10 +195,10 @@ macro_rules! module_device_table { ($table_type: literal, $module_table_name:ident, $table_name:ident) = =3D> { #[rustfmt::skip] #[export_name =3D - concat!("__mod_device_table__", $table_type, - "__", module_path!(), - "_", line!(), - "_", stringify!($table_name)) + concat!("__mod_device_table__", line!(), + "__kmod_", module_path!(), + "__", $table_type, + "__", stringify!($table_name)) ] static $module_table_name: [::core::mem::MaybeUninit; $table_n= ame.raw_ids().size()] =3D unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) }; diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 00586119a25b7..1260bc2287fba 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1476,7 +1476,7 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, { void *symval; char *zeros =3D NULL; - const char *type, *name; + const char *type, *name, *modname; size_t typelen; static const char *prefix =3D "__mod_device_table__"; =20 @@ -1488,10 +1488,19 @@ void handle_moddevtable(struct module *mod, struct = elf_info *info, if (ELF_ST_TYPE(sym->st_info) !=3D STT_OBJECT) return; =20 - /* All our symbols are of form __mod_device_table____. */ + /* All our symbols are of form __mod_device_table__kmod___= __. */ if (!strstarts(symname, prefix)) return; - type =3D symname + strlen(prefix); + + modname =3D strstr(symname, "__kmod_"); + if (!modname) + return; + modname +=3D strlen("__kmod_"); + + type =3D strstr(modname, "__"); + if (!type) + return; + type +=3D strlen("__"); =20 name =3D strstr(type, "__"); if (!name) --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F3B22FC037; Thu, 18 Sep 2025 08:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182841; cv=none; b=mON1fBALqn1vy7GlOsHxzwWMTWJ9UyApCIA2eHV9hLjqdAzd0Uk4BLu1LeKJyNZ4DzsxD6el4gayl2wvDBJbrifekG+l+cj0qKSyVr3fP4KVs6r5mN+TwZzeyFfEW6WxEAwlD4/msqdISo8MB+pOQVi7iX9WPVtaVgeMwF/YOro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182841; c=relaxed/simple; bh=vYbqTyhJdpmnCLgTyUedk6SBL2Lx8JJ3nF6Bgw6/JdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K83JL19N7zz0pIbRmWmKctoNyyLXCAZRongL50U3JfBOQXn3xR5OEoNPqsxjYd+Sy2jLx8FzoF2A8QCAUtbrHB1nLwiIeXCaInEpvedUCMg5lvXR8B3ToVfoturjjctIa8TuacT3JqMxumg4mUjnthUGIUfjyMi6sjxfDPtCsro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kfp10cVK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kfp10cVK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 148C0C4CEF0; Thu, 18 Sep 2025 08:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182838; bh=vYbqTyhJdpmnCLgTyUedk6SBL2Lx8JJ3nF6Bgw6/JdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kfp10cVKPJAwhRmUiL7ulatniuhZhlDLOQ73Aib603FIqO8k38K/zNntb9/2ZMaXd JcypoFnwFItghUpJZ5iSYXSVqBMlO6T0jCDRLo9AnPV1vPqH6PeDW/jQEWVrVuNq8j xx8lCNk3zpHSKqjOgLn8L5MHFkUv3PUaCO288pECbFJ+wG5+UI95KAAziCA/Fa8q0q U7T2G8/dBgUdCGMpH1GTqvfYWcsg3JYdUyOK3Se6lbITaLQVKAuJpTmT2pPaFz+13I eoeX9oGjaxtEzl09LRp8OwKrhI1nPJc3hq2IdkVDFJ51YGGbhZ32VZEdbZhTb6i8V3 aYKQKNmnDbxeg== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov , Masahiro Yamada , Stephen Rothwell Subject: [PATCH v8 7/8] modpost: Create modalias for builtin modules Date: Thu, 18 Sep 2025 10:05:51 +0200 Message-ID: <28d4da3b0e3fc8474142746bcf469e03752c3208.1758182101.git.legion@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For some modules, modalias is generated using the modpost utility and the section is added to the module file. When a module is added inside vmlinux, modpost does not generate modalias for such modules and the information is lost. As a result kmod (which uses modules.builtin.modinfo in userspace) cannot determine that modalias is handled by a builtin kernel module. $ cat /sys/devices/pci0000:00/0000:00:14.0/modalias pci:v00008086d0000A36Dsv00001043sd00008694bc0Csc03i30 $ modinfo xhci_pci name: xhci_pci filename: (builtin) license: GPL file: drivers/usb/host/xhci-pci description: xHCI PCI Host Controller Driver Missing modalias "pci:v*d*sv*sd*bc0Csc03i30*" which will be generated by modpost if the module is built separately. To fix this it is necessary to generate the same modalias for vmlinux as for the individual modules. Fortunately '.vmlinux.export.o' is already generated from which '.modinfo' can be extracted in the same way as for vmlinux.o. Signed-off-by: Masahiro Yamada Signed-off-by: Alexey Gladkov Tested-by: Stephen Rothwell Reviewed-by: Nicolas Schier --- include/linux/module.h | 4 ---- scripts/Makefile.vmlinux | 4 +++- scripts/mksysmap | 3 +++ scripts/mod/file2alias.c | 19 ++++++++++++++++++- scripts/mod/modpost.c | 15 +++++++++++++++ scripts/mod/modpost.h | 2 ++ 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index e31ee29fac6b7..e135cc79aceea 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -256,14 +256,10 @@ struct module_kobject *lookup_or_create_module_kobjec= t(const char *name); __PASTE(type, \ __PASTE(__, name))))) =20 -#ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ static typeof(name) __mod_device_table(type, name) \ __attribute__ ((used, alias(__stringify(name)))) -#else /* !MODULE */ -#define MODULE_DEVICE_TABLE(type, name) -#endif =20 /* Version of form [:][-]. * Or for CVS/RCS ID version, everything but the number is stripped. diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index ce79461714979..1e5e37aadcd05 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -89,11 +89,13 @@ endif remove-section-y :=3D .modinfo remove-section-$(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS) +=3D '.rel*' =20 +remove-symbols :=3D -w --strip-symbol=3D'__mod_device_table__*' + # To avoid warnings: "empty loadable segment detected at ..." from GNU obj= copy, # it is necessary to remove the PT_LOAD flag from the segment. quiet_cmd_strip_relocs =3D OBJCOPY $@ cmd_strip_relocs =3D $(OBJCOPY) $(patsubst %,--set-section-flags %= =3Dnoload,$(remove-section-y)) $< $@; \ - $(OBJCOPY) $(addprefix --remove-section=3D,$(remo= ve-section-y)) $@ + $(OBJCOPY) $(addprefix --remove-section=3D,$(remo= ve-section-y)) $(remove-symbols) $@ =20 targets +=3D vmlinux vmlinux: vmlinux.unstripped FORCE diff --git a/scripts/mksysmap b/scripts/mksysmap index a607a0059d119..c4531eacde202 100755 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -59,6 +59,9 @@ # EXPORT_SYMBOL (namespace) / __kstrtabns_/d =20 +# MODULE_DEVICE_TABLE (symbol name) +/ __mod_device_table__/d + # ------------------------------------------------------------------------= --- # Ignored suffixes # (do not forget '$' after each pattern) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 1260bc2287fba..7da9735e7ab3e 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1477,7 +1477,7 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, void *symval; char *zeros =3D NULL; const char *type, *name, *modname; - size_t typelen; + size_t typelen, modnamelen; static const char *prefix =3D "__mod_device_table__"; =20 /* We're looking for a section relative symbol */ @@ -1500,6 +1500,7 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, type =3D strstr(modname, "__"); if (!type) return; + modnamelen =3D type - modname; type +=3D strlen("__"); =20 name =3D strstr(type, "__"); @@ -1526,5 +1527,21 @@ void handle_moddevtable(struct module *mod, struct e= lf_info *info, } } =20 + if (mod->is_vmlinux) { + struct module_alias *alias; + + /* + * If this is vmlinux, record the name of the builtin module. + * Traverse the linked list in the reverse order, and set the + * builtin_modname unless it has already been set in the + * previous call. + */ + list_for_each_entry_reverse(alias, &mod->aliases, node) { + if (alias->builtin_modname) + break; + alias->builtin_modname =3D xstrndup(modname, modnamelen); + } + } + free(zeros); } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5ca7c268294eb..47c8aa2a69392 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2067,11 +2067,26 @@ static void write_if_changed(struct buffer *b, cons= t char *fname) static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf =3D { }; + struct module_alias *alias, *next; =20 buf_printf(&buf, "#include \n"); =20 add_exported_symbols(&buf, mod); + + buf_printf(&buf, + "#include \n" + "#undef __MODULE_INFO_PREFIX\n" + "#define __MODULE_INFO_PREFIX\n"); + + list_for_each_entry_safe(alias, next, &mod->aliases, node) { + buf_printf(&buf, "MODULE_INFO(%s.alias, \"%s\");\n", + alias->builtin_modname, alias->str); + list_del(&alias->node); + free(alias->builtin_modname); + free(alias); + } + write_if_changed(&buf, ".vmlinux.export.c"); free(buf.p); } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 9133e4c3803f0..2aecb8f25c87e 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -99,10 +99,12 @@ buf_write(struct buffer *buf, const char *s, int len); * struct module_alias - auto-generated MODULE_ALIAS() * * @node: linked to module::aliases + * @modname: name of the builtin module (only for vmlinux) * @str: a string for MODULE_ALIAS() */ struct module_alias { struct list_head node; + char *builtin_modname; char str[]; }; =20 --=20 2.51.0 From nobody Sat Sep 27 19:27:44 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A1632FC87C; Thu, 18 Sep 2025 08:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182842; cv=none; b=T/8JCuk7IkdWBejhru2ju2FwZ8EUFrhu51wCsiyJjFbc+zOzESg3fRZJQ9IuPiCZNHwsF0RaxiaoRGr+lI+brQQgA/g5Fz4LtxOMOmW0mmvObHGUGvWxzaIESG4mgs+U+GLX3pjDK803CH9WORP7PIsk7rXnUdqjMgpiWsoPIN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758182842; c=relaxed/simple; bh=QftOzJsbNOGWTMHdJU6pkH/OLZmiw9UUKgy8+RhpRvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nmK7hFX3I469NVXTfQnW9p2AnKOhEnYQYne92Qi3kfdTygkhgs3Vep4M+Gv8L1M3kmhjibtfkQ35D3MkXep2qSfXoV8s8R57auPOoLwGFbrSlK1scdc/58HpgbTy4+Mkj1IvPxSbAj3wy99Ih4YBXDM7XSStTqYgQSaRAU085To= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KDrkSLdO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KDrkSLdO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A7CAC4CEE7; Thu, 18 Sep 2025 08:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758182841; bh=QftOzJsbNOGWTMHdJU6pkH/OLZmiw9UUKgy8+RhpRvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KDrkSLdOpwziaioIQhkPn36yJBjkb1sQMJDfr+3N8KOGlucHyx700fWl1qpb1/iaq 4uoGX5Ih/WvX47AY2MZ6Bs8Snb56mlNrIH026q/AtW6OcqGAxmB28C0g6DCuvRC2vP lYtrSOPk6YxHerAo4aRsqIpltscRPHEqz/FeM3+H4FJ+YyhFJZfZR9Q/BRmGsGIZWX MZcOnzwLE92e0RezHHAnV6GAN+IHVgwJd3AzGM4aptxS5JS3aGviImiu3KCA2snVlk soRLAMgJXfkmBynDSr0vHteF+RLTeRMcypmF99K1UwLgsiV7AcCXNkPSSdWNz3itq/ faMQ6xh3JknpQ== From: Alexey Gladkov To: Nathan Chancellor , Nicolas Schier , Petr Pavlu , Luis Chamberlain , Sami Tolvanen , Daniel Gomez Cc: linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org, Alexey Gladkov Subject: [PATCH v8 8/8] kbuild: vmlinux.unstripped should always depend on .vmlinux.export.o Date: Thu, 18 Sep 2025 10:05:52 +0200 Message-ID: <0e63a9c7741fe8217e4fd7c60afcf057ffa2ef5a.1758182101.git.legion@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since .vmlinux.export.c is used to add generated by modpost modaliases for builtin modules the .vmlinux.export.o is no longer optional and should always be created. The generation of this file is not dependent on CONFIG_MODULES. Signed-off-by: Alexey Gladkov --- scripts/Makefile.vmlinux | 9 ++------- scripts/link-vmlinux.sh | 5 +---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux index 1e5e37aadcd05..7c6ae9886f8f7 100644 --- a/scripts/Makefile.vmlinux +++ b/scripts/Makefile.vmlinux @@ -53,11 +53,6 @@ endif # vmlinux.unstripped # ------------------------------------------------------------------------= --- =20 -ifdef CONFIG_MODULES -targets +=3D .vmlinux.export.o -vmlinux.unstripped: .vmlinux.export.o -endif - ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX vmlinux.unstripped: arch/$(SRCARCH)/tools/vmlinux.arch.o =20 @@ -72,8 +67,8 @@ cmd_link_vmlinux =3D \ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@"; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) =20 -targets +=3D vmlinux.unstripped -vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE +targets +=3D vmlinux.unstripped .vmlinux.export.o +vmlinux.unstripped: scripts/link-vmlinux.sh vmlinux.o .vmlinux.export.o $(= KBUILD_LDS) FORCE +$(call if_changed_dep,link_vmlinux) ifdef CONFIG_DEBUG_INFO_BTF vmlinux.unstripped: $(RESOLVE_BTFIDS) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 51367c2bfc21e..433849ff7529e 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -73,10 +73,7 @@ vmlinux_link() objs=3D"${objs} .builtin-dtbs.o" fi =20 - if is_enabled CONFIG_MODULES; then - objs=3D"${objs} .vmlinux.export.o" - fi - + objs=3D"${objs} .vmlinux.export.o" objs=3D"${objs} init/version-timestamp.o" =20 if [ "${SRCARCH}" =3D "um" ]; then --=20 2.51.0