[ACCEPTED]-__do_global_dtors_aux and __do_global_ctors_aux-elf
The addresses of constructors and destructors of static objects 11 are each stored in a different section in 10 ELF executable. for the constructors there is a section 9 called .CTORS and for the destructors there is 8 the .DTORS section.
the compiler creates two 7 auxillary functions __do_global_ctors_aux and __do_global_dtors_aux for calling the 6 constructors and destructors of these static 5 objects, respectively.
__do_global_ctors_aux function simply performs 4 a walk on the .CTORS section, while the __do_global_dtors_aux does 3 the same job only for the .DTORS section which 2 contains the program specified destructors 1 functions.
They are auxiliary functions added by the 11 compiler to construct and destroy static 10 objects.
e.g.
std::vector<int> some_global;
int main() { return 0; }
some_global
needs to be actually constructed 9 (and destructed) somewhere, and C++ guarantees 8 that construction happens before main
. One way 7 to do this is to emit a function that happens 6 before main
, which constructs global objects, and 5 another function that happens after main
to 4 destroy them.
If you stuck a breakpoint inside 3 the std::vector
constructor and ran this program, the 2 stack trace would show you the function 1 that it was being initialised from.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.