File: ptrauth-intrinsic-sign-constant.c

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (33 lines) | stat: -rw-r--r-- 1,668 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-intrinsics -emit-llvm %s  -o - | FileCheck %s
// RUN: %clang_cc1 -triple aarch64-elf     -fptrauth-intrinsics -emit-llvm %s  -o - | FileCheck %s

extern int external;

// CHECK: @ptr1 = global ptr ptrauth (ptr @external, i32 0)
void *ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 0);

// CHECK: @ptr2 = global ptr ptrauth (ptr @external, i32 0, i64 1234)
void *ptr2 = __builtin_ptrauth_sign_constant(&external, 0, 1234);

// CHECK: @ptr3 = global ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3)
void *ptr3 = __builtin_ptrauth_sign_constant(&external, 2, &ptr3);

// CHECK: @ptr4 = global ptr ptrauth (ptr @external, i32 2, i64 26, ptr @ptr4)
void *ptr4 = __builtin_ptrauth_sign_constant(&external, 2, __builtin_ptrauth_blend_discriminator(&ptr4, 26));

// CHECK: @ptr5 = global ptr null
void *ptr5;

void test_sign_constant_code() {
// CHECK-LABEL: define {{.*}}void @test_sign_constant_code()
// CHECK-NEXT:  entry:
// CHECK-NEXT:    store ptr ptrauth (ptr @external, i32 0), ptr @ptr1, align 8
// CHECK-NEXT:    store ptr ptrauth (ptr @external, i32 2, i64 1234), ptr @ptr2, align 8
// CHECK-NEXT:    store ptr ptrauth (ptr @external, i32 2, i64 0, ptr @ptr3), ptr @ptr3, align 8
// CHECK-NEXT:    store ptr ptrauth (ptr @external, i32 2, i64 1234, ptr @ptr4), ptr @ptr4, align 8
// CHECK-NEXT:    ret void
  ptr1 = __builtin_ptrauth_sign_constant(&external, 0, 0);
  ptr2 = __builtin_ptrauth_sign_constant(&external, 2, 1234);
  ptr3 = __builtin_ptrauth_sign_constant(&external, 2, &ptr3);
  ptr4 = __builtin_ptrauth_sign_constant(&external, 2, __builtin_ptrauth_blend_discriminator(&ptr4, 1234));
}