[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Use of -ffunction-section, -fdata-section, and --gc-

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Use of -ffunction-section, -fdata-section, and --gc-sections to g et rid of unused code
Date: Wed, 25 Jun 2003 16:33:25 +0200 (MET DST)

"Ebert, Rolf" <address@hidden> wrote:

> I expect that --gc-sections can automatically remove all unused
> functions in the final binary even though they are not in separate
> *.o files.  Is that right?

In effect, it doesn't work.  (For whatever reason, didn't investigate.)

It's a bad idea to support programmer's laziness by trying to automate
this, anyway.  You could easily shoot into your foot by this.  E. g.
suppose you want to place a function like xram() into section .init1,
in order to enable the external RAM interface early.  The linker will
happily remove it since it sees no reference to this function

It's better to properly separate your functions into different source
files (and thus object modules), and then use a library to tell the
linker to only pickup the modules that are actually required.  After
all, this technology has been proven to work for nearly three decades
now on major Unix systems with sometimes hundred or more C sources
per application (and thousands of library files), so i don't see why
one couldn't handle this for a microcontroller with a dozen or two of
source files.

Just MHO, of course.
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]