summaryrefslogtreecommitdiff
path: root/fake-src/strip
blob: 0d1e739de71dd22cc0ecbf9e3b6c3fceaf05df1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
[ "$1" != "-f" -a "$2" != "-f" ] && exec strip "$@"
if [ "$1" = "-f" ]; then
  opts=
  debug="$2"
  file="$3"
  [ $# -ne 3 ] && exit 1
  file "$file" 2>/dev/null | grep -q relocatable && opts=-g
elif [ "$1" = "-g" ]; then
  opts=-g
  debug="$3"
  file="$4"
  [ $# -ne 4 ] && exit 1
else
  exit 1
fi
set -e
objcopy --only-keep-debug "$file" "$debug"
strip $opts "$file"
objcopy --add-gnu-debuglink="$debug" "$file"