#16 strip module symbols

closed-accepted
nobody
None
5
2010-10-18
2010-09-28
amd-65
No

Bei Modulen mit Parametern kann man deutlich mehr Symbole 'strippen'. Parameter haben je ein Symbol __parm_XXXXX und XXXXX. Wenn man diese beiden Symbole beim entfernen ausschließt, kann man alle nicht benötigen Symbole entfernen.

[code]
Index: targets/buildFS
===================================================================
--- targets/buildFS (Revision 137)
+++ targets/buildFS (Arbeitskopie)
@@ -90,10 +90,27 @@
chown -R root:root $TOP_DIR/$ROOTFS/lib
echo "Stripping kernel modules..."
find $TOP_DIR/$ROOTFS/lib/modules -name "*.ko"
-#Modules that need parameters cannot be stripped
-#MODS_KEEPSYM='! -name "ip_conntrack_pt.ko" ! -name "ip_nat_pt.ko"'
-MODS_KEEPSYM='! -name "ip*.ko"'
-eval "find $TOP_DIR/$ROOTFS/lib/modules -name '*.ko' $MODS_KEEPSYM |xargs $STRIP --strip-unneeded"
+MODULES=`find $TOP_DIR/$ROOTFS/lib/modules -name "*.ko"`
+OLD_IFS=$IFS
+IFS=$'\n'
+for MODULE in $MODULES; do
+ SYMBOLS=`objdump -t $MODULE | grep -e "__parm_"`
+ SYMBOLCOUNT=`objdump -t $MODULE | grep -e "__parm_" | wc -l`
+ if [ $SYMBOLCOUNT -gt 0 ]; then
+ KEEPSYMBOLS=""
+ for SYMBOLLINE in $SYMBOLS; do
+ SYMBOL=`echo $SYMBOLLINE | sed 's/.* \(.*\)/\1/'`
+ KEEPSYMBOLS="$KEEPSYMBOLS --keep-symbol=$SYMBOL"
+ SYMBOL=`echo $SYMBOL | sed 's/.*__parm_\(.*\)/\1/'`
+ KEEPSYMBOLS="$KEEPSYMBOLS --keep-symbol=$SYMBOL"
+ done
+ echo $STRIP $MODULE $KEEPSYMBOLS --strip-debug --strip-unneeded
+ eval $STRIP $MODULE $KEEPSYMBOLS --strip-debug --strip-unneeded
+ else
+ $STRIP $MODULE --strip-debug --strip-unneeded
+ fi
+done
+IFS=$OLD_IFS

# Continue to strip user apps and shared libraries using sstrip
echo "Stripping userapps and shared libraries more..."
@@ -103,5 +120,5 @@
depmod -n -a -F$KERNEL_DIR/System.map -b $TOP_DIR/$MOD_DIR 2.6.8.1 >$TOP_DIR/$ROOTFS/lib/modules/2.6.8.1/modules.dep
echo "Checking modules.dep"
check=`cat $TOP_DIR/$ROOTFS/lib/modules/2.6.8.1/modules.dep|grep -e ^/`
-[ "$check" = "" ] && sed -i -e 's/kernel\/net\//\/lib\/modules\/2.6.8.1\/kernel\/net\//g' $TOP_DIR/$ROOTFS/lib/modules/2.6.8.1/modules.dep
+[ "$check" = "" ] && sed -i -e 's/kernel\//\/lib\/modules\/2.6.8.1\/kernel\//g' $TOP_DIR/$ROOTFS/lib/modules/2.6.8.1/modules.dep
echo "Checking done"
[/code]

Discussion

  • Sehr schön, spart bei nem Ipv6 build ca. 20k. Danke wie immer!

     
    • status: open --> closed
     
    • status: closed --> closed-accepted