#!/bin/bash # Strip the given file # Based on Redhat's script (rpm package) stripFile() { if [ ! -f "$1" ] then return 0 fi FILE=`file $1` # Shared libraries.. UNNEEDED=`echo $FILE | grep ' shared object,' | sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'` if [ ! -z "$UNNEEDED" ] then strip -p --strip-unneeded $1 else # Static libraries.. no way to tell if they're stripped already? :/ DEBUG=`echo $FILE | grep -v ' shared object,' | grep ' ar archive'` if [ ! -z "$DEBUG" ] then strip -p --strip-debug $1 else # Unstripped binary BINARY=`echo $FILE | grep -v ' shared object' | sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'` if [ ! -z "$BINARY" -a -x $1 ] then strip -p $1 fi fi fi #FILE=`file $1` # .comment's and .note's #COMNOTE=`echo $FILE | sed -n -e 's/^\(.*\):[ ]*ELF.*, stripped/\1/p'` #if [ ! -z "$COMNOTE" -a -x $1 ] #then #NOTE="-R .note" #if objdump -h $1 | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | grep ALLOC >/dev/null #then #NOTE= #fi #strip -p -R .comment $NOTE $1 #fi }