[package] dnsmasq: add missing config_get, localize variables, bump package revision
[openwrt.git] / scripts / strip-kmod.sh
1 #!/usr/bin/env bash
2 [ -n "$CROSS" ] || {
3 echo "The variable CROSS must be set to point to the cross-compiler prefix"
4 exit 1
5 }
6
7 MODULE="$1"
8
9 [ "$#" -ne 1 ] && {
10 echo "Usage: $0 <module>"
11 exit 1
12 }
13
14 ARGS=
15 if [ -n "$KEEP_SYMBOLS" ]; then
16 ARGS="-X --strip-debug"
17 else
18 ARGS="-x -G __this_module --strip-unneeded"
19 fi
20
21 ${CROSS}objcopy \
22 -R .comment \
23 -R .pdr \
24 -R .mdebug.abi32 \
25 -R .note.gnu.build-id \
26 -R .gnu.attributes \
27 -R .reginfo \
28 $ARGS \
29 "$MODULE" "$MODULE.tmp"
30
31 [ -n "$NO_RENAME" ] && {
32 mv "${MODULE}.tmp" "$MODULE"
33 exit 0
34 }
35
36 ${CROSS}nm "$MODULE.tmp" | awk '
37 BEGIN {
38 n = 0
39 }
40
41 $3 && $2 ~ /[brtd]/ && $3 !~ /\$LC/ && !def[$3] {
42 print "--redefine-sym "$3"=_"n;
43 n = n + 1
44 def[$3] = 1
45 }
46 ' > "$MODULE.tmp1"
47
48 ${CROSS}objcopy `cat ${MODULE}.tmp1` ${MODULE}.tmp ${MODULE}.out
49 mv "${MODULE}.out" "${MODULE}"
50 rm -f "${MODULE}".t*
This page took 0.044206 seconds and 5 git commands to generate.