This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Dropping unused functions out of linked file
- From: Ian Lance Taylor <ian at airs dot com>
- To: "Brian Smith" <bsmith at tytronics dot com dot au>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 25 May 2005 20:23:46 -0400
- Subject: Re: Dropping unused functions out of linked file
- References: <001e01c56186$1414da30$be32000a@HERAKLES>
"Brian Smith" <bsmith@tytronics.com.au> writes:
> Is there any way during the link or compile processes to drop out
> functions and variables that are not used? Part of my source code
> includes generic modules provided by another vendor and I only need
> about 30% of the code that is in those source files. The optimisation
> -Os does not drop them out and I can see no options in the link
> process to do this. I am using the MSP430 port of gcc though this
> seems to be a GCC thing rather than specific to the MSP430 port.
Compile with -ffunction-sections -fdata-sections. Link with
-Wl,--gc-sections. This only works if you are using the GNU linker.
Ian