Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] kbuild: package: Install System.map to build tree only
@ 2026-11-16 15:52 Nicolas Schier
  2026-11-17 15:53 ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Schier @ 2026-11-16 15:52 UTC (permalink / raw)
  To: Thomas Weißschuh, Christian Heusel, Nathan Chancellor
  Cc: linux-kbuild, linux-kernel, Adrián García Casado,
	Nicolas Schier

Unify the installation of System.map for all packaging targets and
install it to the packaged kernel build tree.

Kbuild's scripts/depmod.sh expects System.map to be available in the
build tree to allow depmod to check for unresolved symbols in all
installed kmods.  The script is called by 'modules_install' for in-tree
as well as for out-of-tree modules.

Adrián García Casado reported [1] that the Debian packages produced by
'deb-pkg' or 'bindeb-pkg' do include System.map at /boot/, where
scripts/depmod.sh does not find them and thus refuses to run depmod
after installation of out-of-tree modules built against a packaged
kernel tree.

The 'pacman-pkg' target already installs System.map to the build tree,
while 'deb-pkg', 'rpm-pkg' and 'tar-pkg' install it to /boot.

Replace installation of System.map from all package target specific
scripts by installing System.map to the build tree via
install-extmod-build.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Reported-by: Adrián García Casado <adriangarciacasado42@gmail.com>
Closes: https://lore.kernel.org/linux-kbuild/20261016111106.221542-1-adriangarciacasado42@gmail.com/ # [1]
Signed-off-by: Nicolas Schier <nsc@kernel.org>
---
 scripts/package/PKGBUILD             | 3 +--
 scripts/package/builddeb             | 1 -
 scripts/package/buildtar             | 1 -
 scripts/package/install-extmod-build | 1 +
 scripts/package/kernel.spec          | 5 ++---
 5 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/scripts/package/PKGBUILD b/scripts/package/PKGBUILD
index 66e4b6a37783..ce8e0bff9041 100644
--- a/scripts/package/PKGBUILD
+++ b/scripts/package/PKGBUILD
@@ -90,9 +90,8 @@ _package-headers() {
 		"${srctree}/scripts/package/install-extmod-build" "${builddir}"
 	fi
 
-	echo "Installing System.map and config..."
+	echo "Installing config..."
 	mkdir -p "${builddir}"
-	cp System.map "${builddir}/System.map"
 	cp .config "${builddir}/.config"
 
 	echo "Adding symlink..."
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index ba1defc61652..9f8a4a69059c 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -48,7 +48,6 @@ install_linux_image () {
 		gzip "${pdir}/usr/share/doc/${pname}/config"
 	else
 		mkdir -p "${pdir}/boot"
-		cp System.map "${pdir}/boot/System.map-${KERNELRELEASE}"
 		cp ${KCONFIG_CONFIG} "${pdir}/boot/config-${KERNELRELEASE}"
 	fi
 
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index cc87a473c01f..057ca4fc7d71 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -45,7 +45,6 @@ make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_
 #
 # Install basic kernel files
 #
-cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
 cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
 
diff --git a/scripts/package/install-extmod-build b/scripts/package/install-extmod-build
index f12e1ffe409e..fbf8d3e5ab5f 100755
--- a/scripts/package/install-extmod-build
+++ b/scripts/package/install-extmod-build
@@ -37,6 +37,7 @@ mkdir -p "${destdir}"
 	fi
 
 	echo Module.symvers
+	echo System.map
 	echo "arch/${SRCARCH}/include/generated"
 	echo include/config/auto.conf
 	echo include/config/kernel.release
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 46e80970f723..37a547299a94 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -114,7 +114,6 @@ cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEAS
 # DEPMOD=true makes depmod no-op. We do not package depmod-generated files.
 %{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} %{?install_mod_strip:INSTALL_MOD_STRIP=1} DEPMOD=true modules_install
 %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
-cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE}
 cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
 if %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='test -d ${srctree}/arch/${SRCARCH}/boot/dts' 2>/dev/null; then
 	%{make} %{makeflags} INSTALL_DTBS_PATH=%{buildroot}/lib/modules/%{KERNELRELEASE}/dtb dtbs_install
@@ -132,7 +131,7 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA
 		echo "%ghost /lib/modules/%{KERNELRELEASE}/modules.${x}"
 	done
 
-	for x in System.map config vmlinuz; do
+	for x in config vmlinuz; do
 		echo "%ghost /boot/${x}-%{KERNELRELEASE}"
 	done
 
@@ -185,7 +184,7 @@ rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \
 if [ -x /usr/bin/kernel-install ]; then
 	/usr/bin/kernel-install add %{KERNELRELEASE} /lib/modules/%{KERNELRELEASE}/vmlinuz
 fi
-for file in vmlinuz System.map config; do
+for file in vmlinuz config; do
 	if ! cmp --silent "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"; then
 		cp "/lib/modules/%{KERNELRELEASE}/${file}" "/boot/${file}-%{KERNELRELEASE}"
 	fi

---
base-commit: 7924b82075ab1aee61be04764152cff49257c449
change-id: 20261106-package-install-system-msp-to-build-dir-2b99d8f0714e

Best regards,
--  
Nicolas


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: package: Install System.map to build tree only
  2026-11-16 15:52 [PATCH] kbuild: package: Install System.map to build tree only Nicolas Schier
@ 2026-11-17 15:53 ` sashiko-bot
  2026-11-22 21:35   ` Nathan Chancellor
  0 siblings, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-11-17 15:53 UTC (permalink / raw)
  To: Nicolas Schier, Thomas Weißschuh, Christian Heusel,
	Nathan Chancellor
  Cc: linux-kbuild, Adrián García Casado

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] kbuild: package: System.map dropped from tar-pkg and dir-pkg
  in buildtar
--

commit 4e40237f8938f58bf4db63fc401e165ccfea766e
Author: Nicolas Schier <nsc@kernel.org>

kbuild: package: Install System.map to build tree only

This commit removes the target-specific installation of System.map to
/boot and instead installs System.map into the packaged kernel build tree
via scripts/package/install-extmod-build.

> diff --git a/scripts/package/buildtar b/scripts/package/buildtar
> index cc87a473c01f4..057ca4fc7d71f 100755
> --- a/scripts/package/buildtar
> +++ b/scripts/package/buildtar
> @@ -45,7 +45,6 @@ make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_
>  #
>  # Install basic kernel files
>  #
> -cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
>  cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
>  cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"

[Severity: Medium]
Does removing this copy drop System.map from the tar-pkg and dir-pkg
targets altogether?  Unlike PKGBUILD, builddeb, and kernel.spec, buildtar
does not package a kernel build tree or call
scripts/package/install-extmod-build, so System.map is no longer included
anywhere in the resulting tarball or directory.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-package-install-system-msp-to-build-dir-v1-1-ec53d3d39146@kernel.org?part=1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: package: Install System.map to build tree only
  2026-11-17 15:53 ` sashiko-bot
@ 2026-11-22 21:35   ` Nathan Chancellor
  2026-11-23 15:58     ` Nicolas Schier
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2026-11-22 21:35 UTC (permalink / raw)
  To: Nicolas Schier
  Cc: sashiko-reviews, Thomas Weißschuh, Christian Heusel,
	linux-kbuild, Adrián García Casado

On Tue, Nov 17, 2026 at 03:53:56PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] kbuild: package: System.map dropped from tar-pkg and dir-pkg
>   in buildtar
> --
> 
> commit 4e40237f8938f58bf4db63fc401e165ccfea766e
> Author: Nicolas Schier <nsc@kernel.org>
> 
> kbuild: package: Install System.map to build tree only
> 
> This commit removes the target-specific installation of System.map to
> /boot and instead installs System.map into the packaged kernel build tree
> via scripts/package/install-extmod-build.
> 
> > diff --git a/scripts/package/buildtar b/scripts/package/buildtar
> > index cc87a473c01f4..057ca4fc7d71f 100755
> > --- a/scripts/package/buildtar
> > +++ b/scripts/package/buildtar
> > @@ -45,7 +45,6 @@ make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_
> >  #
> >  # Install basic kernel files
> >  #
> > -cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
> >  cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
> >  cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
> 
> [Severity: Medium]
> Does removing this copy drop System.map from the tar-pkg and dir-pkg
> targets altogether?  Unlike PKGBUILD, builddeb, and kernel.spec, buildtar
> does not package a kernel build tree or call
> scripts/package/install-extmod-build, so System.map is no longer included
> anywhere in the resulting tarball or directory.

Seems legitimate.

This got me thinking a little more about this change and I am not sure
this is actually a good direction to go in. Tying the existence of
System.map to the external module build feels wrong to me since it may
be useful for other tools and /boot/System.map-${KERNELRELEASE} is a
common place for it to be. I think we should probably leave it where it
is in the current set of packaging scripts but symlink it to the
external module build location in the places that need it. Something
like this maybe (completely untested):

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index ba1defc61652..4261963a901e 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -147,6 +147,13 @@ install_kernel_headers () {
 		"${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
 	fi
 
+	if [ "${ARCH}" = um ] ; then
+		system_map="/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
+	else
+		system_map="/boot/System.map-${KERNELRELEASE}"
+	fi
+	ln -s "${system_map}" "${pdir}/usr/src/linux-headers-${version}/System.map"
+
 	mkdir -p $pdir/lib/modules/$version/
 	ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
 }
diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 8f0933cbbe45..3add2b2c7dd2 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -122,6 +122,7 @@ fi
 ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
 %if %{with_devel}
 %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
+ln -fns /lib/modules/%{KERNELRELEASE}/System.map %{buildroot}/usr/src/kernels/%{KERNELRELEASE}/System.map
 %endif
 
 {
-- 
Cheers,
Nathan

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kbuild: package: Install System.map to build tree only
  2026-11-22 21:35   ` Nathan Chancellor
@ 2026-11-23 15:58     ` Nicolas Schier
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Schier @ 2026-11-23 15:58 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: sashiko-reviews, Thomas Weißschuh, Christian Heusel,
	linux-kbuild, Adrián García Casado

On Sun, Nov 22, 2026 at 02:35:04PM -0700, Nathan Chancellor wrote:
> On Tue, Nov 17, 2026 at 03:53:56PM +0000, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 1 potential
> > issue to consider:
> > - [Medium] kbuild: package: System.map dropped from tar-pkg and dir-pkg
> >   in buildtar
> > --
> > 
> > commit 4e40237f8938f58bf4db63fc401e165ccfea766e
> > Author: Nicolas Schier <nsc@kernel.org>
> > 
> > kbuild: package: Install System.map to build tree only
> > 
> > This commit removes the target-specific installation of System.map to
> > /boot and instead installs System.map into the packaged kernel build tree
> > via scripts/package/install-extmod-build.
> > 
> > > diff --git a/scripts/package/buildtar b/scripts/package/buildtar
> > > index cc87a473c01f4..057ca4fc7d71f 100755
> > > --- a/scripts/package/buildtar
> > > +++ b/scripts/package/buildtar
> > > @@ -45,7 +45,6 @@ make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_
> > >  #
> > >  # Install basic kernel files
> > >  #
> > > -cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
> > >  cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
> > >  cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
> > 
> > [Severity: Medium]
> > Does removing this copy drop System.map from the tar-pkg and dir-pkg
> > targets altogether?  Unlike PKGBUILD, builddeb, and kernel.spec, buildtar
> > does not package a kernel build tree or call
> > scripts/package/install-extmod-build, so System.map is no longer included
> > anywhere in the resulting tarball or directory.
> 
> Seems legitimate.
> 
> This got me thinking a little more about this change and I am not sure
> this is actually a good direction to go in. Tying the existence of
> System.map to the external module build feels wrong to me since it may
> be useful for other tools and /boot/System.map-${KERNELRELEASE} is a
> common place for it to be. I think we should probably leave it where it
> is in the current set of packaging scripts but symlink it to the
> external module build location in the places that need it.

As Distros are moving everything to /usr/ -- but I haven't seen
/usr/boot/ anywhere -- I'd prefer to move it away from /boot.  The
kmod build tree looks like the native location to me (as per
scripts/depmod.sh) and from what I can find, most debugging tools use
vmlinux or /proc/kallsyms rather than System.map; but I have never ever
tried to debug a Linux without the full source + build tree at hand.

Does System.map still help with regular debugging with CONFIG_KASLR
enabled?

If it wasn't for 'depmod -e' I'd like to put System.map to the
linux-image-${KVER}-dbg_*.deb, as Debian does.


> Something
> like this maybe (completely untested):
> 
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index ba1defc61652..4261963a901e 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -147,6 +147,13 @@ install_kernel_headers () {
>  		"${srctree}/scripts/package/install-extmod-build" "${pdir}/usr/src/linux-headers-${version}"
>  	fi
>  
> +	if [ "${ARCH}" = um ] ; then
> +		system_map="/usr/lib/uml/modules/${KERNELRELEASE}/System.map"
> +	else
> +		system_map="/boot/System.map-${KERNELRELEASE}"
> +	fi
> +	ln -s "${system_map}" "${pdir}/usr/src/linux-headers-${version}/System.map"
> +

What about doing it the other way round?  We could provide the symlink
in the old /boot/ location for now and move System.map to the module
build tree?



>  	mkdir -p $pdir/lib/modules/$version/
>  	ln -s /usr/src/linux-headers-$version $pdir/lib/modules/$version/build
>  }
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 8f0933cbbe45..3add2b2c7dd2 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -122,6 +122,7 @@ fi
>  ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEASE}/build
>  %if %{with_devel}
>  %{make} %{makeflags} run-command KBUILD_RUN_COMMAND='${srctree}/scripts/package/install-extmod-build %{buildroot}/usr/src/kernels/%{KERNELRELEASE}'
> +ln -fns /lib/modules/%{KERNELRELEASE}/System.map %{buildroot}/usr/src/kernels/%{KERNELRELEASE}/System.map

Looking at line 122 (start of hunk), /lib/modules/%{KERNELRELEASE} seems to be a symlink to
/lib/modules/%{KERNELRELEASE}/build/, thus that line will would create a
funny symlink. ;)


-- 
Nicolas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-23 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 15:52 [PATCH] kbuild: package: Install System.map to build tree only Nicolas Schier
2026-11-17 15:53 ` sashiko-bot
2026-11-22 21:35   ` Nathan Chancellor
2026-11-23 15:58     ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox