[lld] [LLD][COFF] Generate redirection metadata for custom ARM64EC export thunks. (PR #105901)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 15:53:41 PDT 2024


cjacek wrote:

A more detailed explanation of a scenario where this impacts performance can be found in this [blog article](http://www.emulators.com/docs/abc_arm64ec_explained.htm) (search for "EXP+#").

During my experimentation, I had limited success trying to get the MSVC linker to generate executables with the required thunks. While it is possible to pass these thunks similarly to how they are handled in tests, this approach seems less flexible than the implementation I’ve provided here. For instance, exporting the thunks leads to a duplicated symbol error, which I worked around by using the DATA export type to prevent the linker from generating another thunk. However, I wasn’t able to find a way to control the redirection target directly. It appears that MSVC linker reads the contents at an offset expected in EXExportThunkCode and blindly uses that as if it were a generated thunk.

This patch, on the other hand, uses symbol lookup, ensuring consistent behavior akin to how generated code would function. It identifies and treats any thunk chunk resembling an export thunk accordingly.

It depends on #105897 for a corner case when `EXP+` symbol is a weak alias.


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


More information about the llvm-commits mailing list