2006-10-11 06:38:29 +08:00
|
|
|
#!/usr/bin/env bash
|
2006-06-27 08:35:46 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2005-04-21 16:33:23 +08:00
|
|
|
SELF=${0##*/}
|
|
|
|
|
|
|
|
[ -z "$STRIP" ] && {
|
|
|
|
echo "$SELF: strip command not defined (STRIP variable not set)"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
TARGETS=$*
|
|
|
|
|
|
|
|
[ -z "$TARGETS" ] && {
|
|
|
|
echo "$SELF: no directories / files specified"
|
|
|
|
echo "usage: $SELF [PATH...]"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2006-06-01 04:06:46 +08:00
|
|
|
find $TARGETS -type f -a -exec file {} \; | \
|
2017-02-19 21:02:38 +08:00
|
|
|
sed -n -e 's/^\(.*\):.*ELF.*\(executable\|relocatable\|shared object\).*,.*/\1:\2/p' | \
|
2005-04-21 16:33:23 +08:00
|
|
|
(
|
|
|
|
IFS=":"
|
|
|
|
while read F S; do
|
2015-02-10 23:48:48 +08:00
|
|
|
echo "$SELF: $F: $S"
|
2009-03-03 01:33:02 +08:00
|
|
|
[ "${S}" = "relocatable" ] && {
|
2012-02-21 01:38:26 +08:00
|
|
|
eval "$STRIP_KMOD $F"
|
2007-02-10 00:24:34 +08:00
|
|
|
} || {
|
2009-04-21 09:10:21 +08:00
|
|
|
b=$(stat -c '%a' $F)
|
2015-02-10 23:48:48 +08:00
|
|
|
[ -z "$PATCHELF" ] || [ -z "$TOPDIR" ] || {
|
|
|
|
old_rpath="$($PATCHELF --print-rpath $F)"; new_rpath=""
|
|
|
|
for path in $old_rpath; do
|
|
|
|
case "$path" in
|
|
|
|
/lib/[^/]*|/usr/lib/[^/]*|\$ORIGIN/*) new_rpath="${new_rpath:+$new_rpath:}$path" ;;
|
|
|
|
*) echo "$SELF: $F: removing rpath $path" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
[ "$new_rpath" = "$old_rpath" ] || $PATCHELF --set-rpath "$new_rpath" $F
|
|
|
|
}
|
2006-06-01 04:06:46 +08:00
|
|
|
eval "$STRIP $F"
|
2009-04-21 09:10:21 +08:00
|
|
|
a=$(stat -c '%a' $F)
|
|
|
|
[ "$a" = "$b" ] || chmod $b $F
|
2007-02-10 00:24:34 +08:00
|
|
|
}
|
2005-04-21 16:33:23 +08:00
|
|
|
done
|
2007-01-20 09:17:28 +08:00
|
|
|
true
|
2005-04-21 16:33:23 +08:00
|
|
|
)
|