[PATCH 2/2] strip debug information from kernel modules

49 views
Skip to first unread message

Felix Moessbauer

unread,
Sep 13, 2024, 11:16:59 AM9/13/24
to isar-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
If not requested otherwise (e.g. via DEB_BUILD_OPTIONS=nostrip), strip
the debug information from the kernel module. This significantly reduces
the size of the .ko file. As the stripping needs to happen prior to
compression and signing, we need to do it during the build step.

Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 3 +++
meta/recipes-kernel/linux-module/module.inc | 2 ++
2 files changed, 5 insertions(+)

diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
index 7511a17d..ad743437 100755
--- a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
@@ -50,6 +50,9 @@ override_dh_auto_clean:

override_dh_auto_build:
$(MAKE) -C $(KDIR) M=${MODULE_DIR} $(PARALLEL_MAKE) KCFLAGS="${KCFLAGS}" KAFLAGS="${KAFLAGS}" modules
+ifeq ($(filter nostrip,$(DEB_BUILD_OPTIONS)),)
+ find . -name "*.ko" -print -exec strip --strip-debug --remove-section=.note.gnu.build-id {} \;
+endif
ifneq ($(filter pkg.sign,$(DEB_BUILD_PROFILES)),)
find . -name "*.ko" -print -exec $(KDIR)/scripts/sign-file ${SIGNATURE_HASHFN} ${SIGNATURE_KEYFILE} ${SIGNATURE_CERTFILE} {} \;
endif
diff --git a/meta/recipes-kernel/linux-module/module.inc b/meta/recipes-kernel/linux-module/module.inc
index 344dc50f..1734816b 100644
--- a/meta/recipes-kernel/linux-module/module.inc
+++ b/meta/recipes-kernel/linux-module/module.inc
@@ -19,6 +19,8 @@ KERNEL_IMAGE_PKG ??= "linux-image-${KERNEL_NAME}"
KERNEL_HEADERS_PKG ??= "linux-headers-${KERNEL_NAME}"
DEPENDS += "${KERNEL_HEADERS_PKG}-native"
DEBIAN_BUILD_DEPENDS = "${KERNEL_HEADERS_PKG}"
+# Do not generate debug symbols packages, as not supported for modules
+DEB_BUILD_OPTIONS += "noautodbgsym"

SIGNATURE_KEYFILE ??= ""
SIGNATURE_CERTFILE ??= ""
--
2.39.2

Reply all
Reply to author
Forward
0 new messages