__do_global_dtors_aux and __do_global_ctors_aux

后端 未结 2 1366
长情又很酷
长情又很酷 2021-01-02 09:53

I disassembled a simple program written in C++ and there are these two function names. I guess that ctor means constructor and dtor means destructor, and word global maybe m

2条回答
  •  一生所求
    2021-01-02 10:26

    The addresses of constructors and destructors of static objects are each stored in a different section in ELF executable. for the constructors there is a section called .CTORS and for the destructors there is the .DTORS section.

    the compiler creates two auxillary functions __do_global_ctors_aux and __do_global_dtors_aux for calling the constructors and destructors of these static objects, respectively.

    __do_global_ctors_aux function simply performs a walk on the .CTORS section, while the __do_global_dtors_aux does the same job only for the .DTORS section which contains the program specified destructors functions.

提交回复
热议问题