1+ //@ add-minicore
12// ignore-tidy-linelength
23//@ only-aarch64-unknown-linux-pauthtest
34//@ revisions: O0_PAUTH O3_PAUTH
910
1011// Make sure that direct extern "C" calls are not handled by pointer authentication operand bundle
1112// logic.
12- use std:: ffi:: c_void;
13- use std:: hint:: black_box;
13+ #![ feature( no_core, lang_items) ]
14+ #![ no_std]
15+ #![ no_core]
16+ #![ crate_type = "lib" ]
17+
18+ extern crate minicore;
19+ use minicore:: hint:: black_box;
20+ use minicore:: * ;
1421
1522extern "C" {
16- fn rand ( ) -> i32 ;
23+ fn rand ( ) -> bool ;
1724 fn add ( a : i32 , b : i32 ) -> i32 ;
1825 fn sub ( a : i32 , b : i32 ) -> i32 ;
1926
@@ -43,9 +50,9 @@ fn test_indirect_call() {
4350
4451 // Also test calling via conditional pointer
4552 unsafe {
46- // O0_PAUTH: call {{.*}}i32 ptrauth (ptr @rand, i32 0)({{.*}}) #{{[0-9]+}} [ "ptrauth"(i32 0, i64 0) ]
47- // O3_PAUTH: call {{.*}}i32 @rand() #
48- let use_add = rand ( ) % 2 == 0 ;
53+ // O0_PAUTH: call {{.*}}i1 ptrauth (ptr @rand, i32 0)({{.*}}) #{{[0-9]+}} [ "ptrauth"(i32 0, i64 0) ]
54+ // O3_PAUTH: call {{.*}}i1 @rand() #
55+ let use_add = rand ( ) ;
4956 // O0_PAUTH: store ptr ptrauth (ptr @sub, i32 0), ptr %[[FP_O0:[a-zA-Z0-9_.]+]]
5057 // O0_PAUTH: store ptr ptrauth (ptr @add, i32 0), ptr %[[FP_O0]]{{.*}}
5158 // O0_PAUTH: %[[LOAD_FP_O0:[a-zA-Z0-9_.]+]] = load ptr, ptr %[[FP_O0]]{{.*}}
@@ -61,7 +68,7 @@ fn test_indirect_call() {
6168 }
6269}
6370
64- // CHECK-LABE : test_direct_call
71+ // CHECK-LABEL : test_direct_call
6572#[ inline( never) ]
6673fn test_direct_call ( ) {
6774 unsafe {
@@ -78,7 +85,7 @@ fn test_direct_call() {
7885 }
7986}
8087
81- fn main ( ) {
88+ pub fn entry ( ) {
8289 test_indirect_call ( ) ;
8390 test_direct_call ( ) ;
8491}
0 commit comments