kirkwood: find active Linksys root partition
[openwrt/staging/luka.git] / scripts / strip-kmod.sh
index 789364f97bbced62345dc5af179142522640a711..e3f13bee4766d6611bb526a6b867ee0a3d48f805 100755 (executable)
@@ -12,13 +12,20 @@ MODULE="$1"
 }
 
 ARGS=
-[ -n "$KEEP_SYMBOLS" ] || ARGS="-x -G __this_module --strip-unneeded"
+if [ -n "$KEEP_SYMBOLS" ]; then
+       ARGS="-X --strip-debug"
+else
+       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 \
@@ -34,9 +41,10 @@ BEGIN {
        n = 0
 }
 
-$3 && $2 ~ /[brtd]/ && $3 !~ /\$LC/ {
+$3 && $2 ~ /[brtd]/ && $3 !~ /\$LC/ && !def[$3] {
        print "--redefine-sym "$3"=_"n;
        n = n + 1
+       def[$3] = 1
 }
 ' > "$MODULE.tmp1"