[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 9 Feb 2022 23:43:37 +0000 (15:43 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 4 Apr 2022 18:17:36 +0000 (11:17 -0700)
commit786c89fed379186972521895acad6c6a9878af26
tree45064c65bf25d9b6f3f04d9ec304b5bed757fbad
parent45c2371c0d313778256fce2edc5189436581fc20
[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes

This ELF note is aarch64 and Android-specific. It specifies to the
dynamic loader that specific work should be scheduled to enable MTE
protection of stack and heap regions.

Current synthesis of the ".note.android.memtag" ELF note is done in the
Android build system. We'd like to move that to the compiler. This patch
adds the --memtag-stack, --memtag-heap, and --memtag-mode={async, sync,
none} flags to the linker, which synthesises the note for us.

Future changes will add -fsanitize=memtag* flags to clang which will
pass these through to lld.

Depends on D119381.

Differential Revision: https://reviews.llvm.org/D119384
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp
lld/test/ELF/aarch64-memtag-android-abi.s [new file with mode: 0644]