As simple as:
-ffunction-sections -Wl,--gc-sections -Wl,-uInterruptVectors
BUT...
use with care. If you miss third option to gcc, you lose all interrupt
functions and a startup code. Also, if you're playing with c++, all global
constructors/destructors will be eliminated.
~d
On Sunday 14 December 2003 14:20, Matthias Weingart wrote:
> How can I tell mcpgcc not to link unused functions into the target?
>
> example:
>
> func1()
> {
> }
>
> func2()
> {
> }
>
> main()
> {
> func1();
> }
>
> func2 should not appear in the elf-file, because it is never called.
>
> I found some gcc options that would do that
>
> -fvtable-gc
> Emit special relocations for vtables and virtual function references so
> that the linker can identify unused virtual functions and zero out vtable
> slots that refer to them. This is most useful with -ffunction-sections' and
> -Wl,--gc-sections', in order to also discard the functions themselves. This
> optimization requires GNU as and GNU ld. Not all systems support this
> option. -Wl,--gc-sections' is ignored without -static'.
>
> But fvtable-gc is not available for mspgcc. Virtual functions and vtables
> sound like c++ options; ok I dont need that, but elimination of
> unsued function would be good.
> Is there a way to achieve this (maybe creating a lib?).
>
> Matthias
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
--
/*****************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) State Polytechnical Univ.
(_Y_.)' ._ ) `._ `. ``-..-' Radio-Physics Departament
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 5403923, 5585314
*****************************************************************/