Even though the command line option suggests that arbitrary system registers may be chosen, the sysreg option for the stack protector guard currently only permits SP_EL0, as this is what the Linux kernel uses. While it makes no sense to permit arbitrary system registers here (which usually have side effects), there is a desire to switch to TPIDR_EL0 or TPIDRRO_EL0 from the Linux side, both of which are part of the base v8.0 AArch64 ISA, and can hold arbitrary 64-bit values without side effects. So add TPIDR_EL0 and TPIDRRO_EL0 to the set of accepted arguments for the -mstack-protected-guard-reg= command line option. For good measure, add TPIDR_EL1, TPIDR_EL2, FAR_EL1 and FAR_EL2 as well, all of which could potentially be useful to privileged software such as the Linux kernel to stash a per-thread pointer to the stack protector guard value. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
74 lines
5.1 KiB
C
74 lines
5.1 KiB
C
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple x86_64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -emit-llvm %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple powerpc64le-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -emit-llvm %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple arm-linux-gnueabi \
|
|
// RUN: -mstack-protector-guard-offset=1024 -emit-llvm %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple thumbv7-linux-gnueabi \
|
|
// RUN: -mstack-protector-guard-offset=1024 -emit-llvm %s -o - | FileCheck %s
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=sp_el0 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-SP
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=tpidrro_el0 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-TPIDRRO
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=tpidr_el0 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-TPIDR-EL0
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=tpidr_el1 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-TPIDR-EL1
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=tpidr_el2 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-TPIDR-EL2
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=far_el1 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-FAR-EL1
|
|
// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
|
|
// RUN: -mstack-protector-guard-offset=1024 -mstack-protector-guard-reg=far_el2 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=AARCH64 --check-prefix=AARCH64-FAR-EL2
|
|
// RUN: %clang_cc1 -mstack-protector-guard=tls -triple riscv64-unknown-elf \
|
|
// RUN: -mstack-protector-guard-offset=44 -mstack-protector-guard-reg=tp \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=RISCV
|
|
// RUN: %clang_cc1 -mstack-protector-guard=tls -triple powerpc64-unknown-elf \
|
|
// RUN: -mstack-protector-guard-offset=52 -mstack-protector-guard-reg=r13 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=POWERPC64
|
|
// RUN: %clang_cc1 -mstack-protector-guard=tls -triple ppc32-unknown-elf \
|
|
// RUN: -mstack-protector-guard-offset=16 -mstack-protector-guard-reg=r2 \
|
|
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=POWERPC32
|
|
void foo(int*);
|
|
void bar(int x) {
|
|
int baz[x];
|
|
foo(baz);
|
|
}
|
|
|
|
// CHECK: !llvm.module.flags = !{{{.*}}[[ATTR1:![0-9]+]], [[ATTR2:![0-9]+]]}
|
|
// CHECK: [[ATTR1]] = !{i32 1, !"stack-protector-guard", !"sysreg"}
|
|
// CHECK: [[ATTR2]] = !{i32 1, !"stack-protector-guard-offset", i32 1024}
|
|
|
|
// AARCH64: !llvm.module.flags = !{{{.*}}[[ATTR1:![0-9]+]], [[ATTR2:![0-9]+]], [[ATTR3:![0-9]+]]}
|
|
// AARCH64: [[ATTR1]] = !{i32 1, !"stack-protector-guard", !"sysreg"}
|
|
// AARCH64-SP: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"sp_el0"}
|
|
// AARCH64-TPIDRRO: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"tpidrro_el0"}
|
|
// AARCH64-TPIDR-EL0: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"tpidr_el0"}
|
|
// AARCH64-TPIDR-EL1: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"tpidr_el1"}
|
|
// AARCH64-TPIDR-EL2: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"tpidr_el2"}
|
|
// AARCH64-FAR-EL1: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"far_el1"}
|
|
// AARCH64-FAR-EL2: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"far_el2"}
|
|
// AARCH64: [[ATTR3]] = !{i32 1, !"stack-protector-guard-offset", i32 1024}
|
|
|
|
// RISCV: !llvm.module.flags = !{{{.*}}[[ATTR1:![0-9]+]], [[ATTR2:![0-9]+]], [[ATTR3:![0-9]+]], [[ATTR4:![0-9]+]]}
|
|
// RISCV: [[ATTR1]] = !{i32 1, !"stack-protector-guard", !"tls"}
|
|
// RISCV: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"tp"}
|
|
// RISCV: [[ATTR3]] = !{i32 1, !"stack-protector-guard-offset", i32 44}
|
|
|
|
// POWERPC64: !llvm.module.flags = !{[[ATTR1:![0-9]+]], [[ATTR2:![0-9]+]], [[ATTR3:![0-9]+]]}
|
|
// POWERPC64: [[ATTR1]] = !{i32 1, !"stack-protector-guard", !"tls"}
|
|
// POWERPC64: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"r13"}
|
|
// POWERPC64: [[ATTR3]] = !{i32 1, !"stack-protector-guard-offset", i32 52}
|
|
|
|
// POWERPC32: !llvm.module.flags = !{[[ATTR1:![0-9]+]], [[ATTR2:![0-9]+]], [[ATTR3:![0-9]+]]}
|
|
// POWERPC32: [[ATTR1]] = !{i32 1, !"stack-protector-guard", !"tls"}
|
|
// POWERPC32: [[ATTR2]] = !{i32 1, !"stack-protector-guard-reg", !"r2"}
|
|
// POWERPC32: [[ATTR3]] = !{i32 1, !"stack-protector-guard-offset", i32 16}
|