1
votes

I am looking for a command which would create complementary file to stripped binary, which was created using command: strip --strip-all foo In fact I would be happy having procedure for creating two part executable: one part being entirely stripped executable and the second part containing all symbols. Stripped executable should have also link to symbol file. The procedure would be analogous to to the one for debug symbols described in objcopy man page:

1.Link the executable as normal. Assuming that is is called "foo" then...

2.Run "objcopy --only-keep-debug foo foo.dbg" to create a file containing the debugging info.

3.Run "objcopy --strip-debug foo" to create a stripped executable.

4.Run "objcopy --add-gnu-debuglink=foo.dbg foo" to add a link to the debugging info into the
stripped executable.

Greetings

1
Is there anything specific you're trying to achieve? If you need the symbols for debugging purposes, just keep the unstripped version of the compiled binary? - Mario
I plan to distribute stripped binary and keep symbols for case when debugging will be required. Sometimes it is not possible just to replace binary with unstripped one, but it is required to debug stripped binary and load symbol file. - user3741172

1 Answers

1
votes

According to http://marcioandreyoliveira.blogspot.dk/2008/03/how-to-debug-striped-programs-with-gdb.html you should save a copy of your compiled executable and strip the executable for deployment. When debugging you can instruct GDB to load symbols from the saved executable. There is no reason for using objcopy, I think.