Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# This will add symbol tables back into binaries (but not debug information)
# For this to work you must first complete the following steps:
# https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29
# Then pass the directory of objects you want to recombine
set -e
if [ -z $1 ] || [ ! -d $1 ];
then
echo "Please pass a directory you want to recombine"
exit 1
fi
echo "We are about to overwrite files in $1 to add symbols, you'll need to modify this script if that's what you want."
exit 1
echo "Modifying files in $1"
for f in $(find $1 -type f);
do
dpath=$(file $f | cut -f6 -d, | cut -f2 -d= | sed -E 's#^([a-f0-9]{2})(.*)#/usr/lib/debug/.build-id/\1/\2.debug#')
if [ ! -z "$dpath" ] && [ -f $dpath ];
then
echo "Modifying $f"
objcopy -g $dpath $dpath.undebug
eu-unstrip -o $f.unstrip $f $dpath.undebug
rm $dpath.undebug
mv $f.unstrip $f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.