On Saturday 14 November 2009 21:04:54 Wayne Uroda wrote:
> > Does msp430-gcc provide any systematic way, such as a generated symbol,
> > from 
> >
> > which a C source file can determine the size of a function? I have a
> > function  for field reprogramming, which is moved to RAM before use, and
> > need to know how many words to move.

> No there is no real way to do this from my experience (especially not at
>  compile time). I did have success with using an empty function after my
>  flash writer and then doing pointer arithmetic to find the size of the
>  flash func, eg
> 
> void A()
> {
> ...
> }
> 
> void B()
> {}
> 
> //find size of A
> sizeofA = B - A; //something like that
> 
> I didn't feel safe doing this though so in the end I just ended up starting
>  at A and copying as much data as I could fit in my buffer because it
>  doesn't matter if you copy far too much, better to be safe than sorry.

That's an ingenious idea, Wayne, but I can well see why you feel uncomfortable 
with it.  Your final method may be inelegant, but it's completely safe and 
loses only a few cycles.

On Saturday 14 November 2009 21:04:54 Peter Jansen wrote:

> Don't know a way of doing this on a function basis, although the compiler
>  outputs this in the .s file. 

Indeed, a .size macro follows every function at the .s level, and I was hoping 
to be able to tap into the output of it.

>  You could do it on a object file basis by
>  changing the linker script. 
> 
> Also you could also use function attributes to put the function in a
>  separate section, then use the linker script to get the start and end
>  addressed of the section to copy.

This last is the way I am doing it at present, but the downside is that I have 
to maintain a special linker file with the added section, and I was hoping to 
avoid this.

-- 
Rick Jenkins <[email protected]>
Hartman Technica           http://www.hartmantech.com 
Phone +1 (403) 230-1987
221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5

Reply via email to