Skip to content

Commit bbab9ab

Browse files
committed
[NFC][compiler-rt][test] when using ptrauth, strip before checking if poisoned
ptrauth stores info in the address of functions, so it's not the right address we should check if poisoned rdar://75246928 Differential Revision: https://reviews.llvm.org/D106199 (cherry picked from commit b316c30)
1 parent 64162b5 commit bbab9ab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler-rt/test/asan/TestCases/Darwin/linked-only.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <string.h>
1111

1212
#include "sanitizer/asan_interface.h"
13+
#if __has_feature(ptrauth_calls)
14+
# include <ptrauth.h>
15+
#endif
1316

1417
void test_shadow(char *p, size_t size) {
1518
fprintf(stderr, "p = %p\n", p);
@@ -23,7 +26,13 @@ int main(int argc, char *argv[]) {
2326
free(p);
2427
// CHECK: =-1=
2528

26-
test_shadow((char *)&main, 1);
29+
char *mainptr;
30+
#if __has_feature(ptrauth_calls)
31+
mainptr = (char *)ptrauth_strip((void *)&main, ptrauth_key_return_address);
32+
#else
33+
mainptr = (char *)&main;
34+
#endif
35+
test_shadow(mainptr, 1);
2736
// CHECK: =-1=
2837

2938
test_shadow((char *)&p, 1);

0 commit comments

Comments
 (0)