diff options
-rw-r--r-- | src/oh-strip.sh | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/oh-strip.sh b/src/oh-strip.sh index c177852..a7ab1b0 100644 --- a/src/oh-strip.sh +++ b/src/oh-strip.sh @@ -53,6 +53,8 @@ main() find "${dir}" -type f -a ! -path '*/debug/*' -a -name '*.so*' | \ while IFS="${CR}" read file; do if file "${file}" | grep 'ELF.*shared' >/dev/null 2>&1; then + file="${file#${dir}}" + file="/${file##/}" strip_so "${file}" fi done @@ -61,12 +63,16 @@ main() while IFS="${CR}" read file; do if file "${file}" | grep -E 'ELF.*(executable|shared)' \ >/dev/null 2>&1; then + file="${file#${dir}}" + file="/${file##/}" strip_exe "${file}" fi done find "${dir}" -type f -a ! -path '*/debug/*' \ -a -name 'lib*.a' -a ! -name '*_g.a' | while IFS="{CR}" read file; do + file="${file#${dir}}" + file="/${file##/}" strip_a "${file}" done } @@ -81,7 +87,7 @@ strip_so() fi ${STRIP} --remove-section=.comment --remove-section=.note \ - --strip-unneeded "${file}" + --strip-unneeded "${dir}/${file}" if [ -n "${debug}" ]; then link_debug "${file}" "${debug}" @@ -98,7 +104,7 @@ strip_exe() fi ${STRIP} --remove-section=.comment --remove-section=.note \ - "${file}" + "${dir}/${file}" if [ -n "${debug}" ]; then link_debug "${file}" "${debug}" @@ -109,19 +115,20 @@ strip_a() { file="${1}" - ${STRIP} --strip-debug "${file}" + ${STRIP} --strip-debug "${dir}/${file}" } keep_debug() { + file="${1}" build_id_parts='' debug='' - if ! file "${file}" | grep 'not stripped' >/dev/null 2>&1; then + if ! file "${dir}/${file}" | grep 'not stripped' >/dev/null 2>&1; then return fi - build_id_parts="$(${READELF} -n "${file}" | \ + build_id_parts="$(${READELF} -n "${dir}/${file}" | \ sed -n 's/^.*Build ID: \([0-9a-f][0-9a-f]\)\([0-9a-f]*\)$/\1 \2/p')" if [ -z "${build_id_parts}" ]; then return @@ -133,7 +140,7 @@ keep_debug() mkdir -p "${dir}/${debug%/*}" ${OBJCOPY} --only-keep-debug --compress-debug-sections \ - "${file}" "${dir}/${debug}" + "${dir}/${file}" "${dir}/${debug}" chmod 644 "${dir}/${debug}" printf '%s\n' "${debug}" @@ -144,7 +151,7 @@ link_debug() file="${1}" debug="${2}" - ${OBJCOPY} --add-gnu-debuglink="${dir}/${debug}" "${file}" + ${OBJCOPY} --add-gnu-debuglink="${dir}/${debug}" "${dir}/${file}" } main "${@}" |