00001 /* Startup routines for NetWare. 00002 Contributed by Jan Beulich (jbeulich@novell.com) 00003 Copyright (C) 2004 Free Software Foundation, Inc. 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 GCC is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to 00019 the Free Software Foundation, 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. */ 00021 00022 #include <stddef.h> 00023 #include <stdint.h> 00024 #include "unwind-dw2-fde.h" 00025 00026 int __init_environment (void *); 00027 int __deinit_environment (void *); 00028 00029 00030 #define SECTION_DECL(name, decl) decl __attribute__((__section__(name))) 00031 00032 SECTION_DECL(".ctors", void(*const __CTOR_LIST__)(void)) 00033 = (void(*)(void))(intptr_t)-1; 00034 SECTION_DECL(".ctors$_", void(*const __CTOR_END__)(void)) = NULL; 00035 00036 SECTION_DECL(".dtors", void(*const __DTOR_LIST__)(void)) 00037 = (void(*)(void))(intptr_t)-1; 00038 SECTION_DECL(".dtors$_", void(*const __DTOR_END__)(void)) = NULL; 00039 00040 /* No need to use the __[de]register_frame_info_bases functions since 00041 for us the bases are NULL always anyway. */ 00042 void __register_frame_info (const void *, struct object *) 00043 __attribute__((__weak__)); 00044 void *__deregister_frame_info (const void *) __attribute__((__weak__)); 00045 00046 SECTION_DECL(".eh_frame", /*const*/ uint32_t __EH_FRAME_BEGIN__[]) = { }; 00047 SECTION_DECL(".eh_frame$_", /*const*/ uint32_t __EH_FRAME_END__[]) = {0}; 00048 00049 int 00050 __init_environment (void *unused __attribute__((__unused__))) 00051 { 00052 void (* const * pctor)(void); 00053 static struct object object; 00054 00055 if (__register_frame_info) 00056 __register_frame_info (__EH_FRAME_BEGIN__, &object); 00057 00058 for (pctor = &__CTOR_END__ - 1; pctor > &__CTOR_LIST__; --pctor) 00059 if (*pctor != NULL) 00060 (*pctor)(); 00061 00062 return 0; 00063 } 00064 00065 int 00066 __deinit_environment (void *unused __attribute__((__unused__))) 00067 { 00068 /* This should be static to prevent calling the same destructor 00069 twice (just in case where we get here multiple times). */ 00070 static void (* const * pdtor)(void) = &__DTOR_LIST__ + 1; 00071 00072 while (pdtor < &__DTOR_END__) 00073 if (*pdtor++ != NULL) 00074 pdtor[-1] (); 00075 00076 if (__deregister_frame_info) 00077 __deregister_frame_info(__EH_FRAME_BEGIN__); 00078 00079 return 0; 00080 }
1.5.6