static vs shared libraries and global dtors

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

 



Hi,

Assume i have a static library "mylibc.a". I have a shared object "foo.so" which is statically linked with "mylibc.a". I also have my executable "myexe" which is statically linked with "mylibc.a" and dynamically linked with "foo.so".

My question is; how are global destructors(global objects in "foo.so" and "myexe") handled in this case?

As i understand;
1) The dynamic loader after mapping in "foo.so" calls its "_init()" to run its global ctors 
2) It then calls the main executable's "_start()" to start the main app. "_start()" registers its "_fini()" (to run its global dtors) with "atexit()" and then calls its "_init()" and after that passes control to "main()". 

So how is "foo.so"s "_fini()" registered with the atexit() stack? It is supposed to be called after the main executable's "_fini()" has been called. Also how is the technique extended to N shared libs?

Thanks
Ram

Ramanathan Ramadass
Sr. Software Engineer,
Performance Analysis - Broadband,
Spirent Communications, 
Voice: 408-752-7310
Fax: 408-752-7186
mailto:ramanathan.ramadass@xxxxxxxxxxxxxx
http://www.spirentcom.com







[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