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: init code


dreese@vandals.uidaho.edu 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


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