dreese@xxxxxxxxxxxxxxxxxx wrote:
Does gcc currently posses the functionality to do the following?
I would like to have gcc compile in a function that initializes a global variable into the target programs memory space. I need this initialization function to be called before any code is executed from the target program. I need to have gcc do this for every program that it compiles with out being asked.
Does anyone have any ideas?
Look at: __attribute__((constructor))
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html
You would have to force the object containing the constructor to be linked to any program where this behavior is desired.
David Daney