Default said:
What exactly are you trying to accomplish? Why would you want to load a
function in a particular place? It sounds like a case of fixing the
wrong problem. If you tell us what your real goal is, we may be able to
help.
Brian Rodenborn
Brian,
There are times when a function needs to be in one location for
execution, but reside in another.
One example is programming a Flash Memory. The functions for
programming a Flash memory can reside in the Flash. However,
many Flash's do not support simultaneous execution (read) and
programming. Because of this, the code to program the Flash
must be relocated before it is executed. In the system that
I am working on, the code to program a sector of the Flash
must be copied into RAM and then executed. During
initialization, the code is copied into a reserved area into
RAM and function pointers are set appropriately.
As far as I have researched (and I did post to this newsgroup)
there is no method to copy a function from one location to
another. There is no standard method for obtaining either
the length of a function nor its ending address.
In my system, the issue of moving code into another location
was best accomplished by writing all of the code in assembly
language (including the code to move it).
--
Thomas Matthews
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book