Created
May 5, 2018 12:02
-
-
Save Leandros/5bd41243519adcbf4e9b506f606ef205 to your computer and use it in GitHub Desktop.
This file contains 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 | |
cflags="-O3 -std=c++14 -ggdb3 -frecord-gcc-switches" | |
ldflags="-grecord-gcc-switches -gcolumn-info" | |
# Cleanup | |
rm -rf obj | |
rm test test.pdb | |
mkdir -p obj | |
# Objects | |
g++ $cflags -MMD -MF obj/foo.d -c -o obj/foo.o foo.cpp | |
g++ $cflags -MMD -MF obj/io.d -c -o obj/io.o io.cpp | |
# Create our debug info | |
ld -r -b binary -o obj/cc.o obj/foo.d obj/io.d | |
objcopy --rename-section=.data=.ccinfo obj/cc.o | |
objcopy --set-section-flags .ccinfo=debug obj/cc.o | |
# Link step | |
g++ $ldflags -o test obj/cc.o obj/foo.o obj/io.o | |
# Setup debug info | |
objcopy --only-keep-debug test test.pdb | |
strip test | |
objcopy --remove-section .GCC.command.line test | |
objcopy --remove-section .ccinfo test | |
objcopy --add-gnu-debuglink=test.pdb test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment