[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: Bernd Trog
Subject: Re: [avr-gcc-list] Use of -ffunction-section, -fdata-section, and --gc-sections to g et rid of unused code
Date: Thu, 26 Jun 2003 09:18:44 -0700 (PDT)

On Wed, 25 Jun 2003, Joerg Wunsch wrote:

> "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 works for me :)
Well, only -ffunction-section and --gc-sections works. -fdata-section
ICEd avr-gcc.

I've modified the avrN.x linker scripts to tell the linker to KEEP() the
the heads of the depandacy-trees.

> It's a bad idea to support programmer's laziness by trying to automate
> this, anyway.

Why? All programmers I know are lazy ;-)

> 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
> anywhere.

You have to tell the linker about it ...

> It's better to properly separate your functions into different source

Why is it better?

> 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.

Sure you can!
But for me it's much more fun if I can put as many subprograms
in one file as *I* like to do, while not to worry about if all subprograms 
will be used or not. (Their are enough other things to worry about)

> Just MHO, of course.

Yep, everyone should choose the tools which (s)he is most comfortable
to work with!

I'm comfortable when the linker is doing the job I've told it to do - YMMV.

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

reply via email to

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