X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/2685b0601715829f499608a3a2c6f2a79713fbc2..f4c650032291dc644ff2f7e30fd8bcf963f7eb00:/scripts/strip-kmod.sh diff --git a/scripts/strip-kmod.sh b/scripts/strip-kmod.sh index 68da9e901..13e6b5800 100755 --- a/scripts/strip-kmod.sh +++ b/scripts/strip-kmod.sh @@ -11,25 +11,37 @@ MODULE="$1" exit 1 } +ARGS= +if [ -n "$KEEP_SYMBOLS" ]; then + ARGS="-X --strip-debug" +else + ARGS="-x -G __this_module --strip-unneeded" +fi + ${CROSS}objcopy \ - --strip-unneeded \ -R .comment \ -R .pdr \ -R .mdebug.abi32 \ -R .note.gnu.build-id \ -R .gnu.attributes \ -R .reginfo \ - -G __this_module \ - -x "$MODULE" "$MODULE.tmp" + $ARGS \ + "$MODULE" "$MODULE.tmp" + +[ -n "$NO_RENAME" ] && { + mv "${MODULE}.tmp" "$MODULE" + exit 0 +} ${CROSS}nm "$MODULE.tmp" | awk ' 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"