1 // RUN: %clangxx_asan %s -o %t 2 // RUN: not %run %t 0 2>&1 | FileCheck %s 3 // RUN: not %run %t n 2>&1 | FileCheck %s -check-prefix=CHECK -check-prefix=NON_EXEC 4 5 #include <assert.h> 6 char array[42]; 7 8 typedef void void_f(); 9 int main(int argc, char **argv) { 10 void_f *func; 11 assert(argc > 1); 12 if (argv[1][0] == '0') { 13 func = (void_f *)0x04; 14 } else { 15 assert(argv[1][0] == 'n'); 16 func = (void_f *)array; 17 } 18 19 func(); 20 // x86 reports the SEGV with both address=X and pc=X. 21 // On PowerPC64 ELFv1, the pointer is taken to be a function-descriptor 22 // pointer out of which three 64-bit quantities are read. This will SEGV, but 23 // the compiler is free to choose the order. As a result, the address is 24 // either X, X+0x8 or X+0x10. The pc is still in main() because it has not 25 // actually made the call when the faulting access occurs. 26 // CHECK: DEADLYSIGNAL 27 // CHECK: {{AddressSanitizer: (SEGV|access-violation).*(address|pc) }} 28 // NON_EXEC: PC is at a non-executable region. Maybe a wild jump? 29 return 0; 30 } 31