* William Tambe: > I would like for GCC to automatically generate instructions to > initialize global variables without having to manually create a > function with attribute((constructor)) to initialize those global > variables. In the example below from my previous email, GCC should > automatically generate instructions to initialize myglobal just like > it generates instructions to initialize mylocal; except those > instructions to initialize myglobal are to be generated within the > crti.S _init function: > > void myfunc (void) {} > void *myglobal = myfunc; > void main (void) { > void *mylocal = myfunc; > } I believe this would be best implemented in the link editor. It sees the relocations and can generate the appropriate code. However, for position-indepedent code, usually a table-based approach with a minimal loader is typically used.