That's normal. The linker cannot know whether a function inside a compilation unit is perhaps already directly accessed from inside its compilation unit. So if ANY of teh global symbols of this compilation unit is referenced from another module, it will be linked-in completely.
If you want your code to be linked only if required, you need to put any independent code into its own c file. This is the way the stdlib is done. On the other side, the linker will not include any compilation unit that is not referenced at all, even if it has references to others. So if you e.g. create your interrupt vector table as a separate C file, it will not be linked into the final code, as nobody ever references it. If you need it linked, you'll need to take special care of it. Simplest way is to generate a dummy reference to e.g. the reset vector anywhere in your program. JMGross ----- Ursprüngliche Nachricht ----- Von: Alex Polbach An: [email protected] Gesendet am: 15 Jun 2010 11:02:58 Betreff: [Mspgcc-users] Unused functions occupying unnecessary memory Hi all: 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? I am also posting the output of msp430-objdump with an example of the situation:
