Search code examples
gccspace

Is there a way to strip all functions from an object file that I am not using?


I am trying to save space in my executable and I noticed that several functions are being added into my object files, even though I never call them (the code is from a library).

Is there a way to tell gcc to remove these functions automatically or do I need to remove them manually?


Solution

  • Since I asked this question, GCC 4.5 was released which includes an option to combine all files so it looks like it is just 1 gigantic source file. Using that option, it is possible to easily strip out the unused functions.

    More details here