On Wed, 29 Nov 2023, Martin Storsjö wrote:

and related code in Chromium [2].
The first doesn't mention ARM, but both use const_seg on 64-bits
arches and data_seg on 32 bits.

I wouldn't really take that as an authority for this matter here - I would expect this to be a similar historical mistake; someone has used _WIN64 to distinguish x86 and x64 at a time when no other architectures were relevant in Windows code.


[1]: https://lallouslab.net/2017/05/30/using-cc-tls-callbacks-in-visual-studio-with-your-32-or-64bits-programs/ [2]: https://chromium.googlesource.com/chromium/src/+/lkgr/base/win/dllmain.cc#64

I'll try to write a sensible repro case and build it on all arches. I
don't have ARM Windows machines, I hope that looking at the
cross-compiled executable sections will be enough.

Sure, hopefully inspecting that is enough. Otherwise I can help out running any test binaries you want to inspect (you can probably mail me off-list for that).

I went ahead and tested this myself - and as expected, _WIN64 is indeed the wrong condition.

ARM and ARM64 all use the same section type as x64, it's only x86 which is the odd one out. So like most other similar cases, you'll need to ifdef for e.g. _M_IX86 and use the other common codepath for the rest. It might be good to add a comment that explicitly clarifies which one each of the 4 architectures needs (to indicate that the ifdef isn't a mistake but an intentional choice).

// Martin

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

Reply via email to