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.
--
Grant Edwards grant.b.edwards Yow! Here I am in 53
at B.C. and all I want is a
gmail.com dill pickle!!