summaryrefslogtreecommitdiff
path: root/test/crt/ctor_dtor.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/crt/ctor_dtor.c')
-rw-r--r--test/crt/ctor_dtor.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/crt/ctor_dtor.c b/test/crt/ctor_dtor.c
new file mode 100644
index 000000000..64f188333
--- /dev/null
+++ b/test/crt/ctor_dtor.c
@@ -0,0 +1,22 @@
+// RUN: %clang -fno-use-init-array -g -c %s -o %t.o
+// RUN: %clang -fno-use-init-array -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o -lc %libgcc %crtend %crtn
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+
+// CHECK: ctor()
+// CHECK-NEXT: main()
+// CHECK-NEXT: dtor()
+
+void __attribute__((constructor)) ctor() {
+ printf("ctor()\n");
+}
+
+void __attribute__((destructor)) dtor() {
+ printf("dtor()\n");
+}
+
+int main() {
+ printf("main()\n");
+ return 0;
+}