Author: nbd
Date: 2015-10-30 16:20:12 +0100 (Fri, 30 Oct 2015)
New Revision: 47290

Modified:
   trunk/include/kernel-defaults.mk
   trunk/rules.mk
   trunk/scripts/strip-kmod.sh
Log:
build: Allow kernel modules to set build ID debug symbol

This change adds support for specifying a build ID for kernel modules.
This is done by setting PKG_BUILD_ID to a hexadecimal string, which will
then be passed to the kernel linker. In addition, when this flag is set,
the build ID debug symbol (.note.gnu.build-id) will not be stripped from
the kernel module. 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. This
is useful for keeping track of different versions of a module when doing
experiments and development.

Modules that specify the build ID will be ~100 bytes larger (depending
on the length of the build ID specified). There is no size difference
for kernel modules that do not set this variable.

Signed-off-by: Toke H?\195?\184iland-J?\195?\184rgensen <[email protected]>

Modified: trunk/include/kernel-defaults.mk
===================================================================
--- trunk/include/kernel-defaults.mk    2015-10-30 15:18:22 UTC (rev 47289)
+++ trunk/include/kernel-defaults.mk    2015-10-30 15:20:12 UTC (rev 47290)
@@ -11,7 +11,8 @@
        ARCH="$(LINUX_KARCH)" \
        KBUILD_HAVE_NLS=no \
        CONFIG_SHELL="$(BASH)" \
-       $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
+       $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
+       $(if $(PKG_BUILD_ID),LDFLAGS_MODULE=--build-id=0x$(PKG_BUILD_ID))
 
 ifdef CONFIG_STRIP_KERNEL_EXPORTS
   KERNEL_MAKEOPTS += \

Modified: trunk/rules.mk
===================================================================
--- trunk/rules.mk      2015-10-30 15:18:22 UTC (rev 47289)
+++ trunk/rules.mk      2015-10-30 15:20:12 UTC (rev 47290)
@@ -273,8 +273,9 @@
       STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
     endif
   endif
-  RSTRIP:= \
+  RSTRIP= \
     export CROSS="$(TARGET_CROSS)" \
+               $(if $(PKG_BUILD_ID),KEEP_BUILD_ID=1) \
                $(if $(CONFIG_KERNEL_KALLSYMS),NO_RENAME=1) \
                $(if $(CONFIG_KERNEL_PROFILING),KEEP_SYMBOLS=1); \
     NM="$(TARGET_CROSS)nm" \

Modified: trunk/scripts/strip-kmod.sh
===================================================================
--- trunk/scripts/strip-kmod.sh 2015-10-30 15:18:22 UTC (rev 47289)
+++ trunk/scripts/strip-kmod.sh 2015-10-30 15:20:12 UTC (rev 47290)
@@ -18,11 +18,14 @@
        ARGS="-x -G __this_module --strip-unneeded"
 fi
 
+if [ -z "$KEEP_BUILD_ID" ]; then
+    ARGS="$ARGS -R .note.gnu.build-id"
+fi
+
 ${CROSS}objcopy \
        -R .comment \
        -R .pdr \
        -R .mdebug.abi32 \
-       -R .note.gnu.build-id \
        -R .gnu.attributes \
        -R .reginfo \
        $ARGS \
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to