Add assembler plumbing for sanitize_memtag
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Thu, 1 Dec 2022 18:50:28 +0000 (10:50 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Thu, 1 Dec 2022 18:50:34 +0000 (10:50 -0800)
commit850defb86164f1a68816b21f31529d871400a454
treea22fb0e17658ef38a2d6b9f87ff5da77168613a0
parent7db8ff32bd848330c0e1080377605bd05f4fdc7c
Add assembler plumbing for sanitize_memtag

Extends the Asm reader/writer to support reading and writing the
'.memtag' directive (including allowing it on internal global
variables). Also add some extra tooling support, including objdump and
yaml2obj/obj2yaml.

Test that the sanitize_memtag IR attribute produces the expected asm
directive.

Uses the new Aarch64 MemtagABI specification
(https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst)
to identify symbols as tagged in object files. This is done using a
R_AARCH64_NONE relocation that identifies each tagged symbol, and these
relocations are tagged in a special SHT_AARCH64_MEMTAG_GLOBALS_STATIC
section. This signals to the linker that the global variable should be
tagged.

Reviewed By: fmayer, MaskRay, peter.smith

Differential Revision: https://reviews.llvm.org/D128958
16 files changed:
clang/test/Driver/memtag-stack.c
clang/test/Driver/memtag-stack_lto.c [moved from clang/test/Driver/memtag_lto.c with 85% similarity]
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/MC/MCAsmInfo.h
llvm/include/llvm/MC/MCDirectives.h
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/include/llvm/MC/MCSymbolELF.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCSymbolELF.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
llvm/test/MC/AArch64/global-tagging.ll [new file with mode: 0644]