[PATCH][GCC][AARCH64] Add tests for pointer authentication B-key
gcc/testsuite/ChangeLog * gcc.target/aarch64/return_address_sign_b_1.c: New file. * gcc.target/aarch64/return_address_sign_b_2.c: New file. * gcc.target/aarch64/return_address_sign_b_3.c: New file. * gcc.target/aarch64/return_address_sign_builtin.c: New file. * g++.target/aarch64/return_address_sign_ab_exception.C: New file. * g++.target/aarch64/return_address_sign_b_exception.C: New file. From-SVN: r271954
This commit is contained in:
parent
d301c1a41d
commit
2098f8ec2f
7 changed files with 164 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
|||
2019-06-05 Sam Tebbs <sam.tebbs@arm.com>
|
||||
|
||||
* gcc.target/aarch64/return_address_sign_b_1.c: New file.
|
||||
* gcc.target/aarch64/return_address_sign_b_2.c: New file.
|
||||
* gcc.target/aarch64/return_address_sign_b_3.c: New file.
|
||||
* gcc.target/aarch64/return_address_sign_builtin.c: New file.
|
||||
* g++.target/aarch64/return_address_sign_ab_exception.C: New file.
|
||||
* g++.target/aarch64/return_address_sign_b_exception.C: New file.
|
||||
|
||||
2019-06-05 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR debug/90733
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "--save-temps" } */
|
||||
|
||||
__attribute__((target("branch-protection=pac-ret+leaf")))
|
||||
int foo_a () {
|
||||
throw 22;
|
||||
}
|
||||
|
||||
__attribute__((target("branch-protection=pac-ret+leaf+b-key")))
|
||||
int foo_b () {
|
||||
throw 22;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
try {
|
||||
foo_a ();
|
||||
} catch (...) {
|
||||
try {
|
||||
foo_b ();
|
||||
} catch (...) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-times "paciasp" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "pacibsp" 1 } } */
|
||||
/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 1 } } */
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-mbranch-protection=pac-ret+leaf+b-key --save-temps" } */
|
||||
|
||||
int foo () {
|
||||
throw 22;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
try {
|
||||
foo();
|
||||
} catch (...) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-times ".cfi_b_key_frame" 2 } } */
|
52
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_1.c
Normal file
52
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_1.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Testing return address signing where no combined instructions used. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mbranch-protection=pac-ret+leaf+b-key" } */
|
||||
/* { dg-require-effective-target lp64 } */
|
||||
|
||||
int foo (int);
|
||||
|
||||
/* sibcall only. */
|
||||
int __attribute__ ((target ("arch=armv8.3-a")))
|
||||
func1 (int a, int b)
|
||||
{
|
||||
/* pacibsp */
|
||||
return foo (a + b);
|
||||
/* autibsp */
|
||||
}
|
||||
|
||||
/* non-leaf function with sibcall. */
|
||||
int __attribute__ ((target ("arch=armv8.3-a")))
|
||||
func2 (int a, int b)
|
||||
{
|
||||
/* pacibsp */
|
||||
if (a < b)
|
||||
return b;
|
||||
|
||||
a = foo (b);
|
||||
|
||||
return foo (a);
|
||||
/* autibsp */
|
||||
}
|
||||
|
||||
/* non-leaf function, legacy arch. */
|
||||
int __attribute__ ((target ("arch=armv8.2-a")))
|
||||
func3 (int a, int b, int c)
|
||||
{
|
||||
/* pacibsp */
|
||||
return a + foo (b) + c;
|
||||
/* autibsp */
|
||||
}
|
||||
|
||||
/* eh_return. */
|
||||
void __attribute__ ((target ("arch=armv8.3-a")))
|
||||
func4 (long offset, void *handler, int *ptr, int imm1, int imm2)
|
||||
{
|
||||
/* pacibsp */
|
||||
*ptr = imm1 + foo (imm1) + imm2;
|
||||
__builtin_eh_return (offset, handler);
|
||||
/* autibsp */
|
||||
return;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-times "pacibsp" 4 } } */
|
||||
/* { dg-final { scan-assembler-times "autibsp" 4 } } */
|
18
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_2.c
Normal file
18
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_2.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Testing return address signing where combined instructions used. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mbranch-protection=pac-ret+leaf+b-key" } */
|
||||
/* { dg-require-effective-target lp64 } */
|
||||
|
||||
int foo (int);
|
||||
int bar (int, int);
|
||||
|
||||
int __attribute__ ((target ("arch=armv8.3-a")))
|
||||
func1 (int a, int b, int c)
|
||||
{
|
||||
/* pacibsp */
|
||||
return a + foo (b) + c;
|
||||
/* retab */
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-times "pacibsp" 1 } } */
|
||||
/* { dg-final { scan-assembler-times "retab" 1 } } */
|
22
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_3.c
Normal file
22
gcc/testsuite/gcc.target/aarch64/return_address_sign_b_3.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Testing the disable of return address signing. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mbranch-protection=pac-ret+leaf+b-key" } */
|
||||
/* { dg-require-effective-target lp64 } */
|
||||
|
||||
int bar (int, int);
|
||||
|
||||
int __attribute__ ((target ("arch=armv8.3-a,branch-protection=pac-ret+b-key")))
|
||||
func1_leaf (int a, int b, int c, int d)
|
||||
{
|
||||
return a + b + c + d;
|
||||
}
|
||||
|
||||
int __attribute__ ((target ("arch=armv8.3-a,branch-protection=none")))
|
||||
func2_none (int a, int b, int c, int d)
|
||||
{
|
||||
return c + bar (a, b) + d;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-not "pacibsp" } } */
|
||||
/* { dg-final { scan-assembler-not "autibsp" } } */
|
||||
/* { dg-final { scan-assembler-not "retab" } } */
|
|
@ -0,0 +1,16 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-mbranch-protection=pac-ret+leaf+b-key" } */
|
||||
|
||||
/* The correct pauth instruction should be generated no matter the return
|
||||
address signing key/scope specified in the options. */
|
||||
|
||||
int foo() {
|
||||
/* { dg-final { scan-assembler-times "pacia1716" 1 } } */
|
||||
__builtin_aarch64_pacia1716(0, 0);
|
||||
/* { dg-final { scan-assembler-times "pacib1716" 1 } } */
|
||||
__builtin_aarch64_pacib1716(0, 0);
|
||||
/* { dg-final { scan-assembler-times "autia1716" 1 } } */
|
||||
__builtin_aarch64_autia1716(0, 0);
|
||||
/* { dg-final { scan-assembler-times "autib1716" 1 } } */
|
||||
__builtin_aarch64_autib1716(0, 0);
|
||||
}
|
Loading…
Add table
Reference in a new issue