Thanks a lot for so fast answers!!

I have added both flags to CFLAGS and LDFLAGS and they work just fine.
Very neat solution.

Alex

>On 2010-06-15, Grant Edwards <[email protected]> wrote:
> On 2010-06-15, Alex Polbach <[email protected]> wrote:
>
>> I have been noticing that a function that is not used by any module in
>> program gets linked anyway, occupying some precious amount of memory.
>>
>> Suppose that you were sharing a common module but you only needed
>> some functions of it. Is there a way to avoid linking all the unused
>> functions?
>
> Yes.
>
> Add -ffunction-sections to CFLAGS.
>
> Then link add --gc-sections to LDFLAGS.
>
> If you also want to discard unused variables, add -ffdata-sections
> to the compiler flags.
>
> See the ld and gcc info pages for details.

NB: I haven't tested these options with mspgcc in a long time, but at
    one point several years ago they worked fine.

-- 
Grant Edwards               grant.b.edwards        Yow! Excuse me, but didn't
                                  at               I tell you there's NO HOPE
                              gmail.com            for the survival of OFFSET
                                                   PRINTING?


Reply via email to