Re: [arm-gnu] Image size reduction with linker optimization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] Image size reduction with linker optimization



On Thu, Feb 05, 2009 at 07:41:59AM -0800, Michael Downing wrote:
> I am developing a program using CodeSourcery Lite and the ST drivers for
> the STM32 family.  I am calling only a few functions in the ST driver
> files, and yet I see ALL of the functions of those files included,
> whether they are called or not.  I want to minimize my image size by
> getting rid of this unused code.

The key options for reducing unused code in an executable are:

* Link with --gc-sections.  This will only help.

* If that does not help enough on its own, also compile with
-ffunction-sections -fdata-sections.  This can cause larger and slower
code in some cases for kept functions, but increases the amount that
--gc-sections can remove.

Do those help?

-- 
Daniel Jacobowitz
CodeSourcery