DymOK93 / DymOK93/KTL

Fix CXX initializers

Open
#269 1 comment 0 reactions 1 assignee Claimed by @DymOK93 View on GitHub
bug
Dominant language
C++
Stars
99
Forks
21
PR merge metrics
No merged PRs in 30d

Description

Recent MSVC compiler uses
```c++
using ktl::crt::global_c_handler_t = int(__cdecl*)();
using ktl::crt::global_cxx_handler_t = void(__cdecl*)();

CRTALLOC(".CRT$XIA")
ktl::crt::global_c_handler_t __xi_a[] {nullptr}; // C initializers (first)
CRTALLOC(".CRT$XIZ")
ktl::crt::global_c_handler_t __xi_z[] {nullptr}; // C initializers (last)
CRTALLOC(".CRT$XCA")
ktl::crt::global__cxx_handler_t __xc_a[] {nullptr}; // C++ initializers (first)
CRTALLOC(".CRT$XCZ")
ktl::crt::global_cxx_handler_t __xc_z[] {nullptr}; // C++ initializers (last)
CRTALLOC(".CRT$XPA")
ktl::crt::global_cxx_handler_t __xp_a[] {nullptr}; // C pre-terminators (first)
CRTALLOC(".CRT$XPZ")
ktl::crt::global_cxx_handler_t __xp_z[] {nullptr}; // C pre-terminators (last)
CRTALLOC(".CRT$XTA")
ktl::crt::global_cxx_handler_t __xt_a[] {nullptr}; // C terminators (first)
CRTALLOC(".CRT$XTZ")
ktl::crt::global_cxx_handler_t __xt_z[] {nullptr}; // C terminators (last)
```
instead of [old initializers provided by KTL](https://github.com/DymOK93/KTL/blob/master/runtime/include/crt_runtime.hpp).

Usually MSVC places C++ initializers between `__cxx_ctors_begin__` and `__cxx_ctors_end__` symbols as expected, but with LTO enabled (`/GL` compiler option) includes these symbols in reverse order into a weird `?__cxx_c` section without the initializers themselves:

![изображение](https://user-images.githubusercontent.com/66731516/149163435-9e4d12bd-c8c5-497f-a54e-c053fdb6791b.png)

Reproducible on MSVC 19.28+

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.