Created
July 18, 2013 13:43
-
-
Save fcamel/6029402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ref. http://sourceware.org/gdb/onlinedocs/gdb/Index-Files.html | |
if [ $# -ne 1 ]; then | |
echo -e "$0 <binary>\n" | |
echo -e "Add gdb index to <binary>\n" | |
exit 1 | |
fi | |
binary="$1" | |
dir="${binary%/*}" | |
echo "> Getting gdb index from $binary ..." | |
time gdb -nx --batch-silent -ex "file $binary" -ex "save gdb-index $dir" | |
echo -e "\n> Insert gdb index into $binary ..." | |
if [ -f "${binary}.gdb-index" ]; then | |
time objcopy --add-section .gdb_index="${binary}.gdb-index" --set-section-flags .gdb_index=readonly "$binary" "$binary" | |
rm -f "${binary}.gdb-index" | |
fi | |
echo -e "\n> Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment