a.c (441B)
1 /* INIT_ARRAY + FINI_ARRAY: ctor sets g_ctor_ran; test_main checks it. 2 * Dtor sets g_dtor_ran; test_post_fini checks it. */ 3 static int g_ctor_ran = 0; 4 static int g_dtor_ran = 0; 5 6 static void __attribute__((constructor)) init(void) { g_ctor_ran = 1; } 7 static void __attribute__((destructor)) fini(void) { g_dtor_ran = 1; } 8 9 int test_main(void) { return g_ctor_ran == 1 ? 0 : 1; } 10 int test_post_fini(void) { return g_dtor_ran == 1 ? 0 : 1; }