source: trunk/scripts/strip-kmod.sh @ 30964

Last change on this file since 30964 was 30964, checked in by nbd, 5 years ago

kernel: improve profiling support, keep static symbols when profiling is enabled

  • Property svn:executable set to *
File size: 816 bytes
Line 
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
7MODULE="$1"
8
9[ "$#" -ne 1 ] && {
10        echo "Usage: $0 <module>"
11        exit 1
12}
13
14ARGS=
15if [ -n "$KEEP_SYMBOLS" ]; then
16        ARGS="-X --strip-debug"
17else
18        ARGS="-x -G __this_module --strip-unneeded"
19fi
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 '
37BEGIN {
38        n = 0
39}
40
41$3 && $2 ~ /[brtd]/ && $3 !~ /\$LC/ {
42        print "--redefine-sym "$3"=_"n;
43        n = n + 1
44}
45' > "$MODULE.tmp1"
46
47${CROSS}objcopy `cat ${MODULE}.tmp1` ${MODULE}.tmp ${MODULE}.out
48mv "${MODULE}.out" "${MODULE}"
49rm -f "${MODULE}".t*
Note: See TracBrowser for help on using the repository browser.