This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there something like sizeof(function) ?

Note: This was originally posted on 7th May 2009 at http://forums.arm.com

I want to do IAP (In-Application Programming). In order to do this, I will copy several C functions from IROM to IRAM and then execute them there. If there was a sizeof operator for functions than it would be trivial but AFAIK there is none.

To accomplish this, I have created dummy start_of_module & end_of_module marker functions to get addresses of them. That way, I can calculate the size of the module and copy all of functions and find their relative addresses, but I noticed that the compiled functions may be ordered different than they appear in source code. I see this by reading the assembly listing of the module.

Some functions are static but that is all there is...

Any info/suggestion , linker hack , whatever ?

Thanks In Advance...

EOT
  • Note: This was originally posted on 8th May 2009 at http://forums.arm.com

    > *SNIP*

    You must NOT enable "Optimize for Time"
    You must check ASM output for Optimized builds
    The function must have 1 and only 1 exit point
    The function can not have static & const variables
    The function can not access non-local/non-param variables
    The function can not have hidden const variable (note[0])


    > *SNIP*

    That's a pretty long list of things which won't work. If optimization for time causes things to break you may find other optimizations possible with O3 OSpace also cause problems.

    Samar has the right idea. Linkers (generally) manage code and data references by manipulating sections and then fixing up inter-section references if the section moves (called relocations). Moving sections around (and performing appropriate relocations if they are needed) means that code stays functional relative to other addresses in the same section.