[lld] [LLD][COFF] Replace ARM64EC TLS directory chunks with native chunks when available (PR #212845)

Pedro Miguel Justo via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 06:20:02 PDT 2026


pmsjt wrote:

This is a very long thread and I just came back from vacation so, for now, I'll merely reply to the side-comment that I was quoted on.

> FWIW, this is not just counter-intuitive, but I feel like MSVC approach is just fragile and not entirely correct. The `-arm64xsameaddress` feature depends on the fact that arm64ec object files have a chance to flag functions as such. But if native code is different than EC code and uses callbacks, while EC does not, then that's not the case. If you do that and load the image as EC, then it will try to execute native-only callback and crash. I guess that's not very common as usually both views contain similar enough code, but it still does not feel right. This, combined with the general complications related to the approach, really make me wonder why is it like that.

`-arm64xsameaddress` does not assume or depend on EC and Classic versions of the function having the same implementation - they can contain very different code. If the linker is not able to fuse both into one, it will assign the symbol to a jump-thunk with an associated DVRT with will point at the right implementation.

This means that, even in a case where a Classic process does `CreateThread (... , handle_of_an_ec_process, .... , same_address_function, ...);` (and assuming the module containing  `same_address_function` was loaded at the same addess), the right implementation should be executed.

https://github.com/llvm/llvm-project/pull/212845


More information about the llvm-commits mailing list