On 2011-09-26, Bustamante, Paul <pbustama...@ceit.es> wrote:

> When I have a 10 functions in a file "funcs.c", and I only use one of
> them, when I link to the main program (main.c), all the functions in
> the file "funcs.c" are included in the ".elf" file.
>
> How I can link that only the functions that I use will be included in
> the ".elf" file?

Compile with the -ffunction-sections option (you may also want the
-fdata-sections option), then link with the --gc-sections option.

The -ffunction-sections option will place each function in a separate
memory section (-fdata-sections does the same thing for variables). 

The --gc-sections linker option will discard any sections that are not
referenced.

IIRC, there have been a couple recent versions where support for those
features was broken, but I think it's all fixed now.

-- 
Grant Edwards               grant.b.edwards        Yow! I want EARS!  I want
                                  at               two ROUND BLACK EARS
                              gmail.com            to make me feel warm
                                                   'n secure!!


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to