1// RUN: %clangxx_asan %s -o %t && %run %t | FileCheck %s
2
3#include <stdio.h>
4
5int c = 0;
6
7static void foo() {
8 ++c;
9}
10
11static void fini() {
12 printf(format: "fini\n");
13}
14
15int main() {
16 printf(format: "c=%d\n", c);
17 return 0;
18}
19
20__attribute__((section(".preinit_array")))
21void (*call_foo)(void) = &foo;
22
23__attribute__((section(".init_array")))
24void (*call_foo_2)(void) = &foo;
25
26__attribute__((section(".fini_array")))
27void (*call_foo_3)(void) = &fini;
28
29// CHECK: c=2
30// CHECK: fini
31

source code of compiler-rt/test/asan/TestCases/Linux/init_fini_sections.cpp