Re: Make GCC initialize global variables generating instructions in crti.S _init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux