version 1.2, 2001/05/16 17:14:04
|
version 1.3, 2001/12/03 18:04:58
|
Line 3
|
Line 3
|
#ifdef WANT_DYNAMIC |
#ifdef WANT_DYNAMIC |
typedef void(*structor)(void); |
typedef void(*structor)(void); |
|
|
#if 0 |
|
/* dirty trick to force gcc to be in the data section (see dyn_start) */ |
|
static structor force_to_data[0] = {}; |
|
|
|
/* terminate the Construc/DestrucTORS with a NULL element */ |
|
asm ( ".section .ctors,\"aw\" "); |
|
static structor __CTOR_END__[1]={((structor)0)}; |
|
|
|
asm ( ".section .dtors,\"aw\" "); |
|
static structor __DTOR_END__[1]={((structor)0)}; |
|
#else |
|
__attribute__((section(".ctors"))) |
__attribute__((section(".ctors"))) |
static structor __CTOR_END__[1]={((structor)0)}; |
static structor __CTOR_END__[1]={((structor)0)}; |
|
|
__attribute__((section(".dtors"))) |
__attribute__((section(".dtors"))) |
static structor __DTOR_END__[1]={((structor)0)}; |
static structor __DTOR_END__[1]={((structor)0)}; |
#endif |
|
|
|
static void __do_global_ctors_aux(void) |
static void __do_global_ctors_aux(void) |
{ |
{ |
structor *cf=__DTOR_END__; /* ugly trick to prevent warning */; |
structor *cf=__DTOR_END__; /* ugly trick to prevent warning */ |
for(cf=((__CTOR_END__)-1); (*cf) != (structor)-1; cf--) (*cf)(); |
for(cf=((__CTOR_END__)-1); (*cf) != (structor)-1; cf--) (*cf)(); |
} |
} |
|
|
|
__attribute__((section(".init"))) void _init(); |
__attribute__((section(".init"))) void _init() |
__attribute__((section(".init"))) void _init() |
{ |
{ |
__do_global_ctors_aux(); |
__do_global_ctors_aux(); |