__CTOR_LIST__ not populated
Posted: Sat Aug 17, 2019 4:01 am
Hi!
I am in the process of building proper hosted GCC cross compiler for my OS. I've got it to almost working state but there is one thing I am stuck for a few days already. Global/static (whatever they are called) constructors don't get called at all when linking non-static executables. For static executables everything works as it should.
What I've found for now:
EDIT: I think I am onto something. Some part of the build process is hellbent on putting constructors in .init_array section instead of .ctors. Despite using --disable-initfini-array configure option and adding gcc_cv_initfini_array=no to config.gcc. But if I manually remove .init_array and .fini_array sections from linker script then everything starts to work.
I am in the process of building proper hosted GCC cross compiler for my OS. I've got it to almost working state but there is one thing I am stuck for a few days already. Global/static (whatever they are called) constructors don't get called at all when linking non-static executables. For static executables everything works as it should.
What I've found for now:
- _init function gets called,
- .ctors and .dtors sections are generated when needed,
- .init_array and .fini_array sections are generated but __init_array_start, __init_array_end, __fini_array_start and __fini_array_end symbols are not there,
- __CTOR_LIST__, __CTOR_END__, __DTOR_LIST__ and hidden __DTOR_END__ symbols are there,
- but distance between *_END__ and *_LIST__ symbols is always 8 (single pointer size), which (I assume) is not right,
- __CTOR_LIST__ and __DTOR_LIST__ contain -1 pointer which is correct,
- __CTOR_END__ and __DTOR_END__ all contain single NULL pointer, which is also ok
EDIT: I think I am onto something. Some part of the build process is hellbent on putting constructors in .init_array section instead of .ctors. Despite using --disable-initfini-array configure option and adding gcc_cv_initfini_array=no to config.gcc. But if I manually remove .init_array and .fini_array sections from linker script then everything starts to work.