diff options
author | Mitch Phillips <mitchp@google.com> | 2023-07-31 17:07:26 +0200 |
---|---|---|
committer | Mitch Phillips <mitchp@google.com> | 2023-07-31 17:07:42 +0200 |
commit | ca35a19acab1cf6788c42037bbedeca86e34a455 (patch) | |
tree | b16e7d48f6acafd5d60ea8157047d6e8ff77b7ad /llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp | |
parent | 8a677a7ff0c6f59b392a03108f2dba86d1606183 (diff) | |
download | llvm-ca35a19acab1cf6788c42037bbedeca86e34a455.zip llvm-ca35a19acab1cf6788c42037bbedeca86e34a455.tar.gz llvm-ca35a19acab1cf6788c42037bbedeca86e34a455.tar.bz2 |
[lld] Synthesize metadata for MTE globals
As per the ABI at
https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst,
this patch interprets the SHT_AARCH64_MEMTAG_GLOBALS_STATIC section,
which contains R_NONE relocations to tagged globals, and emits a
SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC section, with the correct
DT_AARCH64_MEMTAG_GLOBALS and DT_AARCH64_MEMTAG_GLOBALSSZ dynamic
entries. This section describes, in a uleb-encoded stream, global memory
ranges that should be tagged with MTE.
We are also out of bits to spare in the LLD Symbol class. As a result,
I've reused the 'needsTocRestore' bit, which is a PPC64 only feature.
Now, it's also used for 'isTagged' on AArch64.
An entry in SHT_AARCH64_MEMTAG_GLOBALS_STATIC is practically a guarantee
from an objfile that all references to the linked symbol are through the
GOT, and meet correct alignment requirements. As a result, we go through
all symbols and make sure that, for all symbols $SYM, all object files
that reference $SYM also have a SHT_AARCH64_MEMTAG_GLOBALS_STATIC entry
for $SYM. If this isn't the case, we demote the symbol to being
untagged. Symbols that are imported from other DSOs should always be
fine, as they're GOT-referenced (and thus the GOT entry either has the
correct tag or not, depending on whether it's tagged in the defining DSO
or not).
Additionally hand-tested by building {libc, libm, libc++, libm, and libnetd}
on Android with some experimental MTE globals support in the
linker/libc.
Reviewed By: MaskRay, peter.smith
Differential Revision: https://reviews.llvm.org/D152921
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp')
0 files changed, 0 insertions, 0 deletions