2 * Copyright (C) 2010 CodeSourcery, Inc.
4 * Permission to use, copy, modify, and distribute this file
5 * for any purpose is hereby granted without fee, provided that
6 * the above copyright notice and this notice appears in all
9 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 /* Handle ELF .{pre_init,init,fini}_array sections. */
14 #include <sys/types.h>
16 #ifdef _HAVE_INITFINI_ARRAY
17 extern void (*__fini_array_start
[]) (void) __attribute__((weak
));
18 extern void (*__fini_array_end
[]) (void) __attribute__((weak
));
20 #ifdef _HAVE_INIT_FINI
21 extern void _fini (void);
24 /* Run all the cleanup routines. */
26 __libc_fini_array (void)
31 count
= __fini_array_end
- __fini_array_start
;
32 for (i
= count
; i
> 0; i
--)
33 __fini_array_start
[i
-1] ();
35 #ifdef _HAVE_INIT_FINI