g++ __static_initialization_and_destruction_0(int, int) - what is it

夙愿已清 提交于 2019-12-02 20:44:13

This doc file seems to tell ya all you'd wanna know about those functions: http://www.nsnam.org/docs/linker-problems.doc

From what I can grok, gcc creates a __static_initialization_and_destruction_0 for every translation unit that needs static constructors to be called. Then it places __do_global_ctors_aux into the .ctors section, which then calls __static_initialization_and_destruction_0 on each translation unit.

The issue seems to be a lot more complex than that though; gcc has to deal with individual object files in an archive, and I think this is how they keep the linker from optimizing out those calls.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!