[AArch64] Support customizing stack protector guard
authorNick Desaulniers <ndesaulniers@google.com>
Mon, 17 May 2021 18:41:24 +0000 (11:41 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Mon, 17 May 2021 18:49:22 +0000 (11:49 -0700)
commit0f417789192e74f9d2fad0f6aee4efc394257176
tree03415c4e2111e4b062db7577106f8894e8d38c13
parentc870e36be1b21c1f306927fc9eb983390e434278
[AArch64] Support customizing stack protector guard

Follow up to D88631 but for aarch64; the Linux kernel uses the command
line flags:

1. -mstack-protector-guard=sysreg
2. -mstack-protector-guard-reg=sp_el0
3. -mstack-protector-guard-offset=0

to use the system register sp_el0 for the stack canary, enabling the
kernel to have a unique stack canary per task (like a thread, but not
limited to userspace as the kernel can preempt itself).

Address pr/47341 for aarch64.

Fixes: https://github.com/ClangBuiltLinux/linux/issues/289
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed By: xiangzhangllvm, DavidSpickett, dmgreen

Differential Revision: https://reviews.llvm.org/D100919
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-protector-guard.c
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll [new file with mode: 0644]