Skip to content

Commit 9160119

Browse files
authored
[clang][Modules] Testing Serializing a struct with a __ptrauth Field #10513
This is a test case for llvm#133500. This test case cannot be added to upstream llvm because upstream currently does not have the __ptrauth qualifier yet. llvm#100830 will add the qualifier, and we shall consider upstreaming this test case when llvm#100830 lands. rdar://143763558 (cherry picked from commit 3af0d75)
1 parent 45de490 commit 9160119

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

clang/test/Modules/ptrauth_struct.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Test serializing a module that contains a struct
2+
// with a ptrauth qualified field.
3+
4+
// RUN: rm -rf %t && mkdir %t
5+
// RUN: split-file %s %t
6+
7+
// The command below should not crash.
8+
// RUN: %clang_cc1 -triple arm64e-apple-macosx -fptrauth-returns \
9+
// RUN: -fptrauth-intrinsics -fptrauth-calls -fptrauth-indirect-gotos \
10+
// RUN: -fptrauth-auth-traps -fmodules -fimplicit-module-maps \
11+
// RUN: -fmodules-cache-path=%t/cache -o %t/tu.o -x c %t/tu.c
12+
13+
//--- tu.c
14+
#include "struct_with_ptrauth_field.h"
15+
16+
int foo(struct T *t) {
17+
return t->s.foo(t->s.v, t->s.v) + t->arr[12];
18+
}
19+
20+
//--- struct_with_ptrauth_field.h
21+
typedef int (* FuncTy) (int, int);
22+
23+
struct S{
24+
FuncTy __ptrauth(0, 1, 1234) foo;
25+
int v;
26+
};
27+
28+
struct T {
29+
struct S s;
30+
char arr[64];
31+
};
32+
33+
//--- module.modulemap
34+
module mod1 {
35+
header "struct_with_ptrauth_field.h"
36+
}

0 commit comments

Comments
 (0)