avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Re: Removal of unused functions


From: Björn Haase
Subject: [avr-gcc-list] Re: Removal of unused functions
Date: Sat, 19 Aug 2006 19:31:45 +0200
User-agent: KMail/1.7.1

> Hello people,
>
> I've read quite a bit about the removal of unused functions when using
> avr-gcc. In particular I've read Jörg's remarks about the automatic
> removal feature being useless and I think this might very well be
> correct. 
Joerg's statement used to be correct but no longer is. In fact there was a 
problem for older versions of binutils. The problem that you have encountered 
is fixed in the most recent cvs version of the binutils. If you don't know 
how to use cvs, you might use some recent snapshot.

> He also made a remark about the feature being hardly maintained 
> and that it might break with future versions of GCC - this again might
> hold true (if I'm not making something wrong).
I don't consider it to be hardly maintained and I don't see any problem that 
might show up with future versions of gcc.

> Here's what I did: First wanted to go the way of least resistance:
>
> CFLAGS += -ffunction-sections
> LDFLAGS += -static -Wl,--gc-sections -Wl,-uInterruptVectors
It's close to what you will be needing:

LDFLAGS += -Wl,--gc-sections 

will do. You might also try

CFLAGS += -fdata-sections

, but that's a feature (removal of unused global static variables) where I 
have strong reasons to expect it to work, but that I never tried myself. 

> Result? The .text secion is completely empty in the output file:
That's exactly what I happens for older versions of avr-ld version that do not 
include my fix for --gc-sections.

BTW.:
With the cvs version of the binutils the following switches are newly 
available:

-Wl,--relax

. Gcc will then replace -- if possible -- call instructions by rcall 
instructions (and jmp -> rjmp respectively). You also will have the following 
switches available:

     --pmem-wrap-around=<val> Make the linker relaxation machine assume that a
                              program counter wrap-around occures at address
                              <val>. Supported values are 16k, 32k and 64k.
     --no-call-ret-replacement The relaxation machine normally will
                               substitute two immediately following call/ret
                               instructions by a single jump instruction.
                               This option disables this optimization.
     --no-stubs If the linker detects to attempt to access
                               an instruction beyond 128k by a reloc that
                               is limited to 128k max, it inserts a jump
                               stub. You can de-active this with this switch.

the --no-stubs option is only relevant for the avr6 devices. You can check if 
your version of avr-ld is new enough by executing

avr-ld --help

. The new options should be documented.

HTH,

Bjoern.




reply via email to

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