1 // RUN: %clang -fno-use-init-array -g -c %s -o %t.o 2 // RUN: %clang -fno-use-init-array -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o -lc %libgcc %crtend %crtn 3 // RUN: %run %t 2>&1 | FileCheck %s 4 5 #include <stdio.h> 6 7 // Ensure the various startup functions are called in the proper order. 8 9 // CHECK: __register_frame_info() 10 // CHECK-NEXT: ctor() 11 // CHECK-NEXT: main() 12 // CHECK-NEXT: dtor() 13 // CHECK-NEXT: __deregister_frame_info() 14 15 struct object; 16 __register_frame_info(const void * fi,struct object * obj)17void __register_frame_info(const void *fi, struct object *obj) { 18 printf("__register_frame_info()\n"); 19 } 20 __deregister_frame_info(const void * fi)21void __deregister_frame_info(const void *fi) { 22 printf("__deregister_frame_info()\n"); 23 } 24 ctor()25void __attribute__((constructor)) ctor() { 26 printf("ctor()\n"); 27 } 28 dtor()29void __attribute__((destructor)) dtor() { 30 printf("dtor()\n"); 31 } 32 main()33int main() { 34 printf("main()\n"); 35 return 0; 36 } 37