>> Any alternatives that would work for Harvard Architecture devices such as the AVR would be welcome.

There are no alternatives that do not have an overhead in the case where
pointers to nested functions are *not* used, which seems unacceptable in
C. You could introduce some kind of pragma for a special kind of pointer
I suppose, but it seems the feature is so little used in C that this would
be overkill.

That is not true. You can allocate the trampolines from a pool of ready-made trampolines, i.e. poieces of code in code space that each use two pointers in data space which hold the actual function pointer and the static chain. These can be provided in a separate module of the static libgcc, together with allocation and deallocation of individual trampolines from the pool (the latter has to be called from the epilogue of functions that use initialize (and thus allocate) trampolines). If your pool is small, you might run out of trampolines before you run out of stack, but for all intents and purposes you have a stack overflow then. You can have special libraries to be linked before libgcc which provide a larger pool of trampolines for programs that need that.

On embedded targets, a large pool of trampolines can be provided with 
incomplete address decoding for
a rom that provides a single trampoline code part, using the code address to 
index into the pointer data.
The data might be dynamically allocated. For targets with MMU, A single page of 
trampoline code parts
can be mapped multiple times as required.
        



Reply via email to