[OpenWrt-Devel] [PATCH] Allow kernel modules to keep build ID debug symbol.

Toke Høiland-Jørgensen toke at toke.dk
Fri Oct 30 06:44:32 EDT 2015

This change adds support for specifying that a particular kernel module
wants to keep its build ID debug symbol (.note.gnu.build-id). This
symbol is exported in sysfs by the kernel (if the kernel is compiled
with CONFIG_KALLSYMS) and so can be used to uniquely identify a version
of a kernel module in a running kernel (if the module is built with
suitable linker options). This is useful for keeping track of different
versions of a module when doing experiments and development.

A kernel module Makefile can specify that the build ID should be kept by
exporting PKG_KEEP_BUILD_ID in the Build/Exports section. This will add
~100 bytes to the size of the .ko (depending on the length of the build
ID specified).

The default is to strip the build ID (as before), so there is no size
difference for kernel modules that do not export this variable.

Signed-off-by: Toke Høiland-Jørgensen <toke at toke.dk>
 scripts/strip-kmod.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/strip-kmod.sh b/scripts/strip-kmod.sh
index 13e6b58..d6fa10d 100755
--- a/scripts/strip-kmod.sh
+++ b/scripts/strip-kmod.sh
@@ -18,11 +18,14 @@ else
 	ARGS="-x -G __this_module --strip-unneeded"
+if [ -z "$PKG_KEEP_BUILD_ID" ]; then
+    ARGS="$ARGS -R .note.gnu.build-id"
 ${CROSS}objcopy \
 	-R .comment \
 	-R .pdr \
 	-R .mdebug.abi32 \
-	-R .note.gnu.build-id \
 	-R .gnu.attributes \
 	-R .reginfo \
 	$ARGS \
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list