1/* { dg-do compile } */ 2/* { dg-require-effective-target ilp32 } */ 3/* { dg-options "-g -O -w" } */ 4 5typedef unsigned _GCC_ATTR_ALIGN_u32t; 6typedef _GCC_ATTR_ALIGN_u32t _Uint32t __attribute__((__aligned__(4))); 7typedef int _Intptrt __attribute__((__mode__(__pointer__))); 8typedef unsigned int _Uintptrt __attribute__((__mode__(__pointer__))); 9typedef _Intptrt ptrdiff_t; 10typedef _Uintptrt uintptr_t; 11typedef _Uint32t Elf32_Word; 12typedef struct list_head list_head_t; 13 14struct list_head { 15 list_head_t *next; 16}; 17 18struct object { }; 19 20struct objlist { 21 struct object *object; 22}; 23 24static uintptr_t ldd(void *frame) __attribute__((__used__)); 25static list_head_t *_dl_all_objects_ptr; 26static void fini_array(struct object *const obj) { 27 if ((dynvec(obj,(unsigned)26)) != ((Elf32_Word)-1)) { 28 unsigned i; 29 const unsigned funcs = (dynvec(obj,(unsigned)28)) / 4; 30 const Elf32_Word fa = (dynvec(obj,(unsigned)26)); 31 const int *const p = relative_relocp(obj); 32 for (i = (funcs ? (funcs - 1) : 0U); i != 0U; i--) { 33 void (*const func)(void) = (void *) p[i]; 34 (*func)(); 35 } 36 } 37} 38static void _do_exit_fini(void) { 39 const struct objlist *o; 40 for (((o)) = ((void *)(((list_head_t *)(_dl_all_objects_ptr))->next)); 41 !((((o))) == ((void *)((list_head_t *)(_dl_all_objects_ptr)))); 42 ((o)) = ((void *)(((list_head_t *)((o)))->next))) 43 fini_array (o->object); 44} 45static uintptr_t ldd (void *frame) { 46 atexit(_do_exit_fini); 47} 48