fix infinite recursion in metadata.pl
[openwrt.git] / scripts / rstrip.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 find_modparams() {
10 FILE="$1"
11 $NM "$FILE" | awk '
12 BEGIN {
13 FS=" "
14 }
15 ($3 ~ /^__module_parm_/) && ($3 !~ /^__module_parm_desc/) {
16 gsub(/__module_parm_/, "", $3)
17 printf "-K " $3 " "
18 }
19 ($2 ~ /r/) && ($3 ~ /__param_/) {
20 gsub(/__param_/, "", $3)
21 printf "-K " $3 " "
22 }
23 '
24 }
25
26
27 SELF=${0##*/}
28
29 [ -z "$STRIP" ] && {
30 echo "$SELF: strip command not defined (STRIP variable not set)"
31 exit 1
32 }
33
34 TARGETS=$*
35
36 [ -z "$TARGETS" ] && {
37 echo "$SELF: no directories / files specified"
38 echo "usage: $SELF [PATH...]"
39 exit 1
40 }
41
42 find $TARGETS -type f -a -exec file {} \; | \
43 sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.* stripped/\1:\2/p' | \
44 (
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"
52 }
53 done
54 true
55 )
This page took 0.042441 seconds and 5 git commands to generate.