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