This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: converting function pointers to/from object pointers


If the functions are reordered, chances are that clone_region_start and
clone_region_end would span not all of the required functions and the
consequence would be that not all of the required code would be copied to RAM
and non-existing code would be called eventually.

So the question is: how can I ensure the ordering of the functions?

I don't think there is a good way short of writing a cumbersome
linker script.

But I don't think that's the right question to ask (or one that
would lead to a robust solution). I think a better question to
ask is: how can one compute the size of a set of text symbols.
The answer to that is also "by writing a linker script," but
the solution to that problem is much easier than trying to order
all the text symbols. In the linker script for your image, save
the dot address in a symbol, say _start, then let the linker
define all the other symbols using wildcards, and then save
the dot address again, say in _end. The size is then the
difference between _start and _end. To compute the value in
your program simply declare _start and _end as symbols with
the appropriate type (char* or unsigned long) in your program
and compute the difference there (or have the linker do the
math and define/declare _size analogously).

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]