| 1 |
786 |
skrzyp |
//==========================================================================
|
| 2 |
|
|
//
|
| 3 |
|
|
// crtendS.c
|
| 4 |
|
|
//
|
| 5 |
|
|
// C runtime support
|
| 6 |
|
|
//
|
| 7 |
|
|
//==========================================================================
|
| 8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
| 9 |
|
|
// -------------------------------------------
|
| 10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
| 11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
| 12 |
|
|
//
|
| 13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
| 14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
| 15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
| 16 |
|
|
// version.
|
| 17 |
|
|
//
|
| 18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 21 |
|
|
// for more details.
|
| 22 |
|
|
//
|
| 23 |
|
|
// You should have received a copy of the GNU General Public License
|
| 24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 26 |
|
|
//
|
| 27 |
|
|
// As a special exception, if other files instantiate templates or use
|
| 28 |
|
|
// macros or inline functions from this file, or you compile this file
|
| 29 |
|
|
// and link it with other works to produce a work based on this file,
|
| 30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
| 31 |
|
|
// the GNU General Public License. However the source code for this file
|
| 32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
| 33 |
|
|
// General Public License v2.
|
| 34 |
|
|
//
|
| 35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
| 36 |
|
|
// on this file might be covered by the GNU General Public License.
|
| 37 |
|
|
// -------------------------------------------
|
| 38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
| 39 |
|
|
//==========================================================================
|
| 40 |
|
|
//#####DESCRIPTIONBEGIN####
|
| 41 |
|
|
//
|
| 42 |
|
|
// Author(s): nickg
|
| 43 |
|
|
// Contributors: nickg
|
| 44 |
|
|
// Date: 2000-11-25
|
| 45 |
|
|
// Purpose: C runtime support
|
| 46 |
|
|
// Description: This file contains code that must appear at the very end of
|
| 47 |
|
|
// a dynamically loaded library. It contains definitions for the
|
| 48 |
|
|
// end of the .init and .fini sections.
|
| 49 |
|
|
//
|
| 50 |
|
|
//####DESCRIPTIONEND####
|
| 51 |
|
|
//
|
| 52 |
|
|
//==========================================================================
|
| 53 |
|
|
|
| 54 |
|
|
#include <pkgconf/system.h>
|
| 55 |
|
|
|
| 56 |
|
|
#include <cyg/loader/loader.hxx>
|
| 57 |
|
|
|
| 58 |
|
|
/*------------------------------------------------------------------------*/
|
| 59 |
|
|
|
| 60 |
|
|
#ifndef INIT_SECTION_ASM_OP
|
| 61 |
|
|
#define INIT_SECTION_ASM_OP ".section\t.init,\"ax\"\n"
|
| 62 |
|
|
#endif
|
| 63 |
|
|
|
| 64 |
|
|
#ifndef FINI_SECTION_ASM_OP
|
| 65 |
|
|
#define FINI_SECTION_ASM_OP ".section\t.fini,\"ax\"\n"
|
| 66 |
|
|
#endif
|
| 67 |
|
|
|
| 68 |
|
|
#ifndef TEXT_SECTION_ASM_OP
|
| 69 |
|
|
#define TEXT_SECTION_ASM_OP ".text\n"
|
| 70 |
|
|
#endif
|
| 71 |
|
|
|
| 72 |
|
|
#ifndef CTORS_SECTION_ASM_OP
|
| 73 |
|
|
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
|
| 74 |
|
|
#endif
|
| 75 |
|
|
|
| 76 |
|
|
#ifndef DTORS_SECTION_ASM_OP
|
| 77 |
|
|
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
|
| 78 |
|
|
#endif
|
| 79 |
|
|
|
| 80 |
|
|
/*------------------------------------------------------------------------*/
|
| 81 |
|
|
|
| 82 |
|
|
typedef void (*pfunc) (void);
|
| 83 |
|
|
|
| 84 |
|
|
#if 1
|
| 85 |
|
|
asm(CTORS_SECTION_ASM_OP);
|
| 86 |
|
|
static pfunc __CTOR_END__[1] __attribute__((unused)) = { (pfunc) 0 };
|
| 87 |
|
|
asm(DTORS_SECTION_ASM_OP);
|
| 88 |
|
|
static pfunc __DTOR_END__[] __attribute__((unused)) = { (pfunc) 0 };
|
| 89 |
|
|
asm( TEXT_SECTION_ASM_OP );
|
| 90 |
|
|
|
| 91 |
|
|
#else
|
| 92 |
|
|
|
| 93 |
|
|
extern pfunc __CTOR_LIST__[];
|
| 94 |
|
|
extern pfunc __CTOR_END__[];
|
| 95 |
|
|
extern pfunc __DTOR_END__[];
|
| 96 |
|
|
|
| 97 |
|
|
#endif
|
| 98 |
|
|
|
| 99 |
|
|
/*------------------------------------------------------------------------*/
|
| 100 |
|
|
|
| 101 |
|
|
static void
|
| 102 |
|
|
cyg_hal_invoke_constructors(void)
|
| 103 |
|
|
{
|
| 104 |
|
|
#if 1
|
| 105 |
|
|
pfunc *p;
|
| 106 |
|
|
|
| 107 |
|
|
for (p = &__CTOR_END__[-1]; *p != (pfunc) -1 ; p--)
|
| 108 |
|
|
(*p) ();
|
| 109 |
|
|
#elif 0
|
| 110 |
|
|
pfunc *p;
|
| 111 |
|
|
|
| 112 |
|
|
for (p = &__CTOR_LIST__[(int)__CTOR_LIST__[0]]; p != &__CTOR_LIST__[0] ; p--)
|
| 113 |
|
|
(*p) ();
|
| 114 |
|
|
#endif
|
| 115 |
|
|
} // cyg_hal_invoke_constructors()
|
| 116 |
|
|
|
| 117 |
|
|
/*------------------------------------------------------------------------*/
|
| 118 |
|
|
|
| 119 |
|
|
static void __attribute__ ((__unused__))
|
| 120 |
|
|
init_dummy (void)
|
| 121 |
|
|
{
|
| 122 |
|
|
asm (INIT_SECTION_ASM_OP);
|
| 123 |
|
|
cyg_hal_invoke_constructors();
|
| 124 |
|
|
}
|
| 125 |
|
|
|
| 126 |
|
|
asm( TEXT_SECTION_ASM_OP );
|
| 127 |
|
|
|
| 128 |
|
|
/*------------------------------------------------------------------------*/
|
| 129 |
|
|
|
| 130 |
|
|
static void __attribute__ ((__unused__))
|
| 131 |
|
|
fini_dummy (void)
|
| 132 |
|
|
{
|
| 133 |
|
|
asm (FINI_SECTION_ASM_OP);
|
| 134 |
|
|
// __do_global_dtors_aux ();
|
| 135 |
|
|
#ifdef FORCE_FINI_SECTION_ALIGN
|
| 136 |
|
|
FORCE_FINI_SECTION_ALIGN;
|
| 137 |
|
|
#endif
|
| 138 |
|
|
}
|
| 139 |
|
|
|
| 140 |
|
|
asm (TEXT_SECTION_ASM_OP);
|
| 141 |
|
|
|
| 142 |
|
|
/*------------------------------------------------------------------------*/
|
| 143 |
|
|
|
| 144 |
|
|
//==========================================================================
|
| 145 |
|
|
// End of crtendS.c
|