[Top][All Lists]

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

Re: [avr-libc-dev] [RFC] Patch adding support for atmega2560-2561

From: David Brown
Subject: Re: [avr-libc-dev] [RFC] Patch adding support for atmega2560-2561
Date: Mon, 19 Sep 2005 09:53:40 +0200

----- Original Message -----
From: "Björn Haase" <address@hidden>

< snip for compactness >

> The method for adding support for the larger devices is the following. The
> function's code is now splitted into two parts for the avr6 devices. A
> part consisting of one single jump stub per function is placed in the
> ".text 1". The rest of the function resides in the section ".text 2".  For
> these devices ".text 0" is meant to be used for initialized program memory
> data that should end up in the lower 64k. The linker will start with
> the objects of ".text 0", then take the ".text 1" and then the ".text 2"
> data. Drawback of this method is that a jump stub is always generated.
> if the function resides in the lower 128k and even if one never takes the
> address of this function. The pattern for the call instructions is changed
> such, that for avr6 it generally jumps directly to the ".text 2" labels in
> order to avoid unnecessary jumping. All indirect calls will make use of
> address of the jump stub. So each indirect call will result in a sequence
> two calls.
> Yours,
> Bjoern
I'm not too hot on the internals of gcc, but I'm wondering if there is not
already a mechanism in place for gcc to detect purely internal linkage (by
which I mean a "static" function whose address is never taken).  When a
function is declared "inline", the compiler has to know whether it must also
generate an "outline" version as well - if it knows the function is "static"
and the address is never taken, the "outline" version is not generated.
Could this also be used to determine if a stub is needed or not?  If this
were possible, then the stub could be avoided by simply declaring functions
to be "static" if they are not needed externally to the file, cutting down
the overhead substantially, since the majority of functions can be labelled
"static".  Of course, that requires a bit of discipline on the part of the
programmer, as they would have to use "static" explicitly on all non-extern
functions.  But that's good practice anyway (and easily checked with
"-Wmissing-prototypes" ).

An alternative idea might be to use individual sections such as ".text1_foo"
for the stub for function foo(), and make use of the "--gc-sections" option
in the linker to remove any such section that is not used.  I'm thinking of
the same idea as the "-ffunction-sections" switch in gcc which can be used
with "--gc-sections" to avoid linking in functions that are not used.  I
haven't tried the "-ffunction-sections" switch, and don't even know if it is
implemented for the avr port, but perhaps the same idea can be used.

Thanks for all your work so far,


reply via email to

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