fix some warnings
[openwrt/crisos.git] / scripts / rstrip.sh
blob6dd44f2ed272c65e84fbedc8d90a42d7dc627864
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2006 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 find_modparams() {
10 FILE="$1"
11 $NM "$FILE" | awk '
12 BEGIN {
13 FS=" "
15 ($3 ~ /^__module_parm_/) && ($3 !~ /^__module_parm_desc/) {
16 gsub(/__module_parm_/, "", $3)
17 printf "-K " $3 " "
19 ($2 ~ /r/) && ($3 ~ /__param_/) {
20 gsub(/__param_/, "", $3)
21 printf "-K " $3 " "
27 SELF=${0##*/}
29 [ -z "$STRIP" ] && {
30 echo "$SELF: strip command not defined (STRIP variable not set)"
31 exit 1
34 TARGETS=$*
36 [ -z "$TARGETS" ] && {
37 echo "$SELF: no directories / files specified"
38 echo "usage: $SELF [PATH...]"
39 exit 1
42 find $TARGETS -type f -a -exec file {} \; | \
43 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
45 IFS=":"
46 while read F S; do
47 echo "$SELF: $F:$S"
48 [ "${F##*\.}" = "o" -o "${F##*\.}" = "ko" ] && {
49 eval "$STRIP_KMOD -w -K '__param*' -K '__mod*' $(find_modparams "$F")$F"
50 } || {
51 eval "$STRIP $F"
53 done
54 true