summaryrefslogtreecommitdiffstats
path: root/src/oh-strip
diff options
context:
space:
mode:
Diffstat (limited to 'src/oh-strip')
-rw-r--r--src/oh-strip27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/oh-strip b/src/oh-strip
index 86e59b9..c03fb43 100644
--- a/src/oh-strip
+++ b/src/oh-strip
@@ -24,6 +24,12 @@ print_usage()
printf 'Usage: %s [-g] [-l] binaryfile...\n' "$1"
}
+error()
+{
+ printf 'oh-strip: Error: %s\n' "${1}"
+ exit 1
+}
+
opts=$(getopt -n "${0}" -o 'gl' -- "${@}")
if [ ${?} -ne 0 ]; then
print_usage "${0}" >&2
@@ -51,8 +57,8 @@ while true; do
esac
done
-if [ -z "${make_dbg_pkg}" ]; then
- make_dbg_pkg=false
+if [ -z "${make_dbg_obj}" ]; then
+ make_dbg_obj=false
fi
if [ -z "${is_lib}" ]; then
is_lib=false
@@ -67,17 +73,20 @@ fi
while [ ${#} -gt 0 ]; do
printf 'oh-strip: Stripping symbols from file "%s"...\n' "${1}"
- # XXX: For some reason, this doesn't seem to work.
-
- if ${make_dbg_pkg}; then
+ if ${make_dbg_obj}; then
# Copy debugging symbols into a debugging object file and add a GDB link
# from the original object file to the debugging object file.
- objcopy --only-keep-debug "dest/${1}" "dest/usr/lib/debug/${1}"
- objcopy --add-gnu-debuglink="/usr/lib/debug/${1}" "dest/${1}"
- chmod 644 "dest/usr/lib/debug/${1}"
+ mkdir -p "$(dirname "dest/usr/lib/debug/${1}")" || \
+ error 'Cannot make directory path to debugging object'
+ objcopy --only-keep-debug --compress-debug-sections "dest/${1}" \
+ "dest/usr/lib/debug/${1}" || error 'Cannot make debugging object'
+ objcopy --add-gnu-debuglink="dest/usr/lib/debug/${1}" "dest/${1}" || \
+ error 'Cannot add GDB link'
+ chmod 644 "dest/usr/lib/debug/${1}" || \
+ error 'Cannot set mode on debugging object'
fi
# Strip the object file of symbols.
# TODO: If the file is not a library, strip it of all symbols.
- strip -g "dest/${1}"
+ strip -g "dest/${1}" || error 'Cannot strip object'
shift
done