1 // Check that ASan correctly detects SEGV on the zero page. 2 // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s 3 4 #if __has_feature(ptrauth_calls) 5 # include <ptrauth.h> 6 #endif 7 8 typedef void void_f(); main()9int main() { 10 void_f *func = (void_f *)0x4; 11 #if __has_feature(ptrauth_calls) 12 func = ptrauth_sign_unauthenticated( 13 func, ptrauth_key_function_pointer, 0); 14 #endif 15 func(); 16 // x86 reports the SEGV with both address=4 and pc=4. 17 // On PowerPC64 ELFv1, the pointer is taken to be a function-descriptor 18 // pointer out of which three 64-bit quantities are read. This will SEGV, but 19 // the compiler is free to choose the order. As a result, the address is 20 // either 0x4, 0xc or 0x14. The pc is still in main() because it has not 21 // actually made the call when the faulting access occurs. 22 // CHECK: {{AddressSanitizer: (SEGV|access-violation).*(address|pc) 0x0*[4c]}} 23 return 0; 24 } 25