[lld] [LLD][COFF] Append a terminator entry to redirection metadata (PR #115202)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 12:01:16 PST 2024


cjacek wrote:

I noticed that the `.a64xrm` section generated by MSVC always includes an additional 8 trailing zeroes, likely serving as a terminator entry. This terminator allows the metadata to be read without knowing its exact size in advance. While the linker exposes this size through `__arm64x_redirection_metadata_count` (part of CHPE metadata), the terminator enables reading until it is encountered, rather than relying on CHPE metadata interpretation.

In my testing, skipping the terminator works fine, though this may be coincidental, as it is typically followed by section padding at runtime. Since adding it is straightforward, it seems reasonable to follow MSVC’s approach.

One notable side effect is that when the redirection metadata is empty, MSVC still emits an `.a64xrm` section containing only 8 zeroes, with `__arm64x_redirection_metadata` pointing to it. In practice, however, most binaries include at least an entry-point redirection.


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


More information about the llvm-commits mailing list