Repository navigation
build: strip kernel modules with --strip-unneeded, not --strip-debug - #2502
Merged
Merged
Conversation
Buildroot installs modules with INSTALL_MOD_STRIP=1, which the kernel turns into `strip --strip-debug`, so every module still ships its full .symtab and .strtab. Any other value is passed to strip as its options; --strip-unneeded keeps the symbols relocation and __ksymtab need and drops the rest. pkg-kernel-module.mk uses the same LINUX_MAKE_FLAGS, so out-of-tree modules are covered too. hi3516ev300_lite: rootfs.squashfs 5096 -> 5052 KB on a clean build.
openipc-ai
requested review from
cronyx,
flyrouter and
viktorxda
as code owners
September 30, 2026 04:41
PR Summary by QodoStrip installed kernel modules with --strip-unneeded
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can route each severity your way: inline, summary, both, or drop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The lite boards keep going over their 5120 KB squashfs cap (#2500 was the latest rescue), and every image ships kernel modules that are only half stripped.
Buildroot's
linux.mkinstalls modules withINSTALL_MOD_STRIP=1, which the kernel's Makefile turns intostrip --strip-debug. That leaves each module's full.symtab/.strtabin place. For any other value, the kernel passes the value tostripas its options.--strip-unneededkeeps exactly the symbols the module loader needs (those referenced by relocations, and the__ksymtabexports) and drops the rest. #2447 already strips the opensdk modules this way on hi3516cv6xx and runs them on hardware.This appends
INSTALL_MOD_STRIP=--strip-unneededtoLINUX_MAKE_FLAGSingeneral/external.mk. It uses the same include-order mechanism as the wpa_supplicant line above it: the last assignment on the make command line wins.pkg-kernel-module.mkinstalls with the sameLINUX_MAKE_FLAGS, so out-of-tree module packages (wireguard, the Wi-Fi drivers) are covered too. Prebuilt vendor blobs are not touched.The cost: an oops inside a module prints offsets instead of the names of its static functions. Exported and global symbols stay.
Hardware tested on
hi3516ev300_lite, IMX335, lab camera 10.216.128.76, running
nightly-20260922-ca38928.To match the running kernel exactly, I tested the camera's own modules. I copied all 26 in-tree modules plus
wireguard.kooff the camera, stripped them here with the board's toolchain, served them back over NFS, and loaded them withinsmod. Nothing was flashed. I then unloaded them and restored the camera's original module set. majestic kept streaming throughout. The vendor media stack was loaded and in use, so it was not touched.One difference from what the build does: the test copies were stripped with
--strip-unneeded --remove-section=.comment --remove-section=.note, while this change passes only--strip-unneeded, which removes strictly less.Evidence
Size, clean builds of
hi3516ev300_liteon master:Before:
After:
That is 44 KB of squashfs back, with no kernel cost. (The "before" is master prior to #2501; the CA bundle adds another 8 KB on top.)
On the camera, the camera's own modules, stripped: 1,827,288 → 1,624,584 B across the 26. Every one loaded with nothing in
dmesgabout unknown symbols, relocations or taint:Then each one was exercised:
There was no USB device attached, so mt7601u, option, cdc_ether and rndis_host were proven to load and register, not to drive hardware.
Local checks:
ci-matrix.py --self-testok.general/external.mkselects the full matrix.Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source