From ba38e0585024837bc59c618bdd2adfd42d2d9af8 Mon Sep 17 00:00:00 2001 From: nbd Date: Sat, 8 Aug 2009 14:22:04 +0000 Subject: add an optional config option for stripping all unnecessary symbol exports from the kernel image git-svn-id: svn://svn.openwrt.org/openwrt/trunk@17181 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- include/kernel-build.mk | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'include/kernel-build.mk') diff --git a/include/kernel-build.mk b/include/kernel-build.mk index d48f8b9f5..e3e446ba5 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -54,6 +54,28 @@ define BuildKernel $(Kernel/Prepare) touch $$@ + $(KERNEL_BUILD_DIR)/symtab.txt: FORCE + find $(LINUX_DIR) $(STAGING_DIR_ROOT)/lib/modules -name \*.ko | \ + xargs $(TARGET_CROSS)nm | \ + awk '$$$$1 == "U" { print $$$$2 } ' | \ + sort -u > $$@ + + $(KERNEL_BUILD_DIR)/symtab.h: $(KERNEL_BUILD_DIR)/symtab.txt + ( \ + echo '#define SYMTAB_KEEP \'; \ + cat $(KERNEL_BUILD_DIR)/symtab.txt | \ + awk '{print "*(__ksymtab." $$$$1 ") \\" }'; \ + echo; \ + echo '#define SYMTAB_KEEP_GPL \'; \ + cat $(KERNEL_BUILD_DIR)/symtab.txt | \ + awk '{print "*(__ksymtab_gpl." $$$$1 ") \\" }'; \ + echo; \ + echo '#define SYMTAB_KEEP_STR \'; \ + cat $(KERNEL_BUILD_DIR)/symtab.txt | \ + awk '{print "*(__ksymtab_strings." $$$$1 ") \\" }'; \ + echo; \ + ) > $$@ + $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config $(Kernel/Configure) touch $$@ @@ -62,7 +84,7 @@ define BuildKernel $(Kernel/CompileModules) touch $$@ - $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE + $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) $(if $(CONFIG_STRIP_KERNEL_EXPORTS),$(KERNEL_BUILD_DIR)/symtab.h) FORCE $(Kernel/CompileImage) touch $$@ -- cgit v1.2.3