[all-commits] [llvm/llvm-project] a2d874: [LLD][COFF] Generate X64 thunks for ARM64EC entry ...

Jacek Caban via All-commits all-commits at lists.llvm.org
Thu Aug 22 13:03:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a2d8743cc86f96f6b1cbd85798328bd3fb2bf4de
      https://github.com/llvm/llvm-project/commit/a2d8743cc86f96f6b1cbd85798328bd3fb2bf4de
  Author: Jacek Caban <jacek at codeweavers.com>
  Date:   2024-08-22 (Thu, 22 Aug 2024)

  Changed paths:
    M lld/COFF/Chunks.cpp
    M lld/COFF/Chunks.h
    M lld/COFF/Driver.cpp
    M lld/COFF/Driver.h
    M lld/COFF/SymbolTable.cpp
    M lld/COFF/SymbolTable.h
    M lld/COFF/Writer.cpp
    A lld/test/COFF/arm64ec-export-thunks.test
    M lld/test/COFF/arm64ec-exports.s
    A lld/test/COFF/arm64ec-patchable-thunks.test

  Log Message:
  -----------
  [LLD][COFF] Generate X64 thunks for ARM64EC entry points and patchable functions. (#105499)

This implements Fast-Forward Sequences documented in ARM64EC
ABI https://learn.microsoft.com/en-us/windows/arm/arm64ec-abi.

There are two conditions when linker should generate such thunks:

- For each exported ARM64EC functions.
It applies only to ARM64EC functions (we may also have pure x64
functions, for which no thunk is needed). MSVC linker creates
`EXP+<mangled export name>` symbol in those cases that points to the
thunk and uses that symbol for the export. It's observable from the
module: it's possible to reference such symbols as I did in the test.
Note that it uses export name, not name of the symbol that's exported
(as in `foo` in `/EXPORT:foo=bar`). This implies that if the same
function is exported multiple times, it will have multiple thunks. I
followed this MSVC behavior.

- For hybrid_patchable functions.
The linker tries to generate a thunk for each undefined `EXP+*` symbol
(and such symbols are created by the compiler as a target of weak alias
from the demangled name). MSVC linker tries to find corresponding
`*$hp_target` symbol and if fails to do so, it outputs a cryptic error
like `LINK : fatal error LNK1000: Internal error during
IMAGE::BuildImage`. I just skip generating the thunk in such case (which
causes undefined reference error). MSVC linker additionally checks that
the symbol complex type is a function (see also #102898). We generally
don't do such checks in LLD, so I made it less strict. It should be
fine: if it's some data symbol, it will not have `$hp_target` symbol, so
we will skip it anyway.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list