This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
When examining a disassembler file of a binary compiled with the msp430 GCC I can find several functions that are unused, blowing out the size of the .text segment.
E.g. several different multiply functions like __mulsi2, __mulsi2_hw32, ... (maybe without/with or with different hardware support ).
For reducing these multiply functions compiling with -ffunction and linking with --gc-sections does the job.
However, there are remaining functions that seem to be unreferenced, e.g. from nosyscalls.o: open, close, kill, getpid, ...
I can't understand why these functions are still linked to the binary. Do they have a certain purpose?
I have let the MSP430 gcc compiler experts know about your issue. I'm sure they will want a test case. Is this organized as a CCS project you could send in?
Thanks and regards,
-George
What means complete port?
We investigated the map file. Actually __crt0_call_exit() calls _exit(). _exit() causes nosyscalls.o to be included which further causes lib_a-errno.o and lib_a-impure.o to be included.
These are quite a lot unused functions bloating the code. How could we finally get rid of unused code?
Since we build all of newlib, we have to provide a few OS-level functions that newlib might call just to make sure you don't have link errors. These functions always fail, but at least they exist .
In your case, if _exit() is being called by crt0, that means gcc thinks your main() function eventually returns. When main() returns, the standards say to call "exit" but of course an MCU can't "exit" so we provide a dummy exit() call. If you change your main() so that gcc sees that it doesn't exit (like, by ending with a while(1) loop of some sort), the call to exit (and thus the other functions) should go away.