31 lines · cpp
1// RUN: %clangxx_asan %s -o %t && %run %t | FileCheck %s2 3#include <stdio.h>4 5int c = 0;6 7static void foo() {8 ++c;9}10 11static void fini() {12 printf("fini\n");13}14 15int main() {16 printf("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=230// CHECK: fini31