Is it possible to write debug information in a separate file when compiling a program with *gcc -g* ?
Issue
Once a program has been compiled with gcc -g, debug information can be written in a separate file using objcopy
# foo.c is compiled with debug options.
$ gcc -g -o foo foo.c
# extract debug information from foo and write them in foo.dbg
$ objcopy --only-keep-debug foo foo.dbg
# remove debug information from foo
$ objcopy --strip-debug foo
# link debug information back to foo
$ objcopy --add-gnu-debuglink=foo.dbg foo
Is it possible to create a separate debug file directly when compiling a program with gcc -g?
Environment
- Red Hat Enterprise Linux 6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
