On Thu, 30 Nov 2023, Antonin Décimo wrote:

The literature online uses `data_seg` on x86 and `const_seg` on x64.
In my tests, using `const_seg` worked on all arches (x86, x64, arm,
arm64).

Hmm, that does indeed seem to be the case - I can confirm this.

We can use `#pragma section` and `__declspec(allocate("xxx"))`
instead.

Umm, this doesn't seem to work for me. With your example code below, with foo_init renamed into main(), I don't get any working TLS callbacks, on neither x86 nor x64, and linking produces the following warning:

LIBCMT.lib(tlssup.obj) : warning LNK4078: multiple '.CRT' sections found with different attributes (40400040) LIBCMT.lib(initializers.obj) : warning LNK4254: section '.CRT' (50000040) merged into '.rdata' (40000040) with different attributes

This is tested and observed with MSVC 2022 17.8.0 and 17.9.1 preview 1.

If I replace your #pragma section with #pragma const_seg, it does work though.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to