1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

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
This commit is contained in:
nbd
2009-08-08 14:22:04 +00:00
parent 321577a2db
commit ba38e05850
5 changed files with 270 additions and 1 deletions

View File

@@ -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 $$@

View File

@@ -22,6 +22,11 @@ KERNEL_MAKEOPTS := -C $(LINUX_DIR) \
KBUILD_HAVE_NLS=no \
CONFIG_SHELL="$(BASH)"
ifdef CONFIG_STRIP_KERNEL_EXPORTS
KERNEL_MAKEOPTS += \
EXTRA_LDSFLAGS="-I$(KERNEL_BUILD_DIR) -include symtab.h"
endif
INITRAMFS_EXTRA_FILES ?= $(GENERIC_PLATFORM_DIR)/image/initramfs-base-files.txt
ifneq (,$(KERNEL_CC))