There are no negative consequences, except that your executable file may be unnecessarily large. The linker may be perhaps a dead band of unused code for you, and that will cut it all. You can use some tool to view objects ( otool , objdump , nm , etc.) in the executable file to find out if there are any additional characters in it.
I use a Mac, so there will be some differences if you use the standard set of gcc tools, but here is an example:
$ make gcc -o app main.c file2.c gcc -Wl,-dead_strip -o app_strip main.c file2.c $ ls -l app* -rwxr-xr-x 1 carl staff 8744 Feb 6 20:05 app -rwxr-xr-x 1 carl staff 8704 Feb 6 20:05 app_strip
I think that in the non-Apple gcc world, you should pass -Wl,--gc-sections instead of -Wl,-dead_strip in my example. The difference in size in the two executable files that you see is due to the fact that the extra function is separated:
$ nm app | cut -c 20- > app.txt $ nm app_strip | cut -c 20- > app_strip.txt $ diff app.txt app_strip.txt 8d7 < _function2
Carl Norum
source share