07_init_array.c (447B)
1 /* Exercises SHT_INIT_ARRAY / SHT_FINI_ARRAY via constructor / destructor 2 * attributes. The constructor and destructor function pointers must 3 * appear as relocations in the respective array sections and survive 4 * the roundtrip intact. */ 5 6 static int state = 0; 7 8 __attribute__((constructor)) static void ctor(void) { state |= 1; } 9 __attribute__((destructor)) static void dtor(void) { state &= ~1; } 10 11 int was_initialized(void) { return state; }