Skip to content

Commit b8b836c

Browse files
ojhuntyuxuanchen1997
authored andcommitted
[clang][test] Add function type discrimination tests to static destructor tests (#99604)
Summary: I accidentally did not include tests for the setting up runtime calls when compiling with -fptrauth-function-pointer-type-discrimination Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251233
1 parent 24477f8 commit b8b836c

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

clang/test/CodeGenCXX/ptrauth-static-destructors.cpp

+31-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22
// RUN: | FileCheck %s --check-prefix=CXAATEXIT
33

44
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
5-
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,DARWIN
5+
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ATEXIT_DARWIN
66

77
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
88
// RUN: | FileCheck %s --check-prefix=CXAATEXIT
99

1010
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
11-
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ELF
11+
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ATEXIT_ELF
12+
13+
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s \
14+
// RUN: -fptrauth-function-pointer-type-discrimination -o - | FileCheck %s --check-prefix=CXAATEXIT_DISC
15+
16+
// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
17+
// RUN: -fptrauth-function-pointer-type-discrimination -fno-use-cxa-atexit \
18+
// RUN: | FileCheck %s --check-prefixes=ATEXIT_DISC,ATEXIT_DISC_DARWIN
19+
20+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s \
21+
// RUN: -fptrauth-function-pointer-type-discrimination -o - | FileCheck %s --check-prefix=CXAATEXIT_DISC
22+
23+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
24+
// RUN: -fptrauth-function-pointer-type-discrimination -fno-use-cxa-atexit \
25+
// RUN: | FileCheck %s --check-prefixes=ATEXIT_DISC,ATEXIT_DISC_ELF
1226

1327
class Foo {
1428
public:
@@ -21,11 +35,22 @@ Foo global;
2135
// CXAATEXIT: define internal void @__cxx_global_var_init()
2236
// CXAATEXIT: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0), ptr @global, ptr @__dso_handle)
2337

38+
// CXAATEXIT_DISC: define internal void @__cxx_global_var_init()
39+
// CXAATEXIT_DISC: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942), ptr @global, ptr @__dso_handle)
2440

2541
// ATEXIT: define internal void @__cxx_global_var_init()
2642
// ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0))
2743

28-
// DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
29-
// ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
30-
// DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
31-
// ELF: call void @_ZN3FooD1Ev(ptr @global)
44+
// ATEXIT_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
45+
// ATEXIT_ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
46+
// ATEXIT_DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
47+
// ATEXIT_ELF: call void @_ZN3FooD1Ev(ptr @global)
48+
49+
// ATEXIT_DISC: define internal void @__cxx_global_var_init()
50+
// ATEXIT_DISC: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0, i64 10942))
51+
52+
53+
// ATEXIT_DISC_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
54+
// ATEXIT_DISC_ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
55+
// ATEXIT_DISC_DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
56+
// ATEXIT_DISC_ELF: call void @_ZN3FooD1Ev(ptr @global)

0 commit comments

Comments
 (0)