Home | History | Annotate | Download | only in Darwin
      1 // A global constructor from a non-instrumented part calls a function
      2 // in an instrumented part.
      3 // Regression test for https://code.google.com/p/address-sanitizer/issues/detail?id=363.
      4 
      5 // RUN: %clangxx      -DINSTRUMENTED_PART=0 -c %s -o %t-uninst.o
      6 // RUN: %clangxx_asan -DINSTRUMENTED_PART=1 -c %s -o %t-inst.o
      7 // RUN: %clangxx_asan %t-uninst.o %t-inst.o -o %t
      8 
      9 // RUN: %run %t 2>&1 | FileCheck %s
     10 
     11 #include <stdio.h>
     12 #include <stdlib.h>
     13 #include <string.h>
     14 
     15 void func(char *ptr);
     16 
     17 #if INSTRUMENTED_PART == 1
     18 
     19 void func(char *ptr) {
     20   *ptr = 'X';
     21 }
     22 
     23 #else // INSTRUMENTED_PART == 1
     24 
     25 struct C1 {
     26   C1() {
     27     printf("Hello ");
     28     char buffer[10] = "world";
     29     func(buffer);
     30     printf("%s\n", buffer);
     31   }
     32 };
     33 
     34 C1 *obj = new C1();
     35 
     36 int main(int argc, const char *argv[]) {
     37   return 0;
     38 }
     39 
     40 #endif // INSTRUMENTED_PART == 1
     41 
     42 // CHECK: Hello Xorld
     43