Back to index

glibc  2.9
initfini.c
Go to the documentation of this file.
00001 /* Special .init and .fini section support for SH.
00002    Copyright (C) 2000, 2002 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    In addition to the permissions in the GNU Lesser General Public
00011    License, the Free Software Foundation gives you unlimited
00012    permission to link the compiled version of this file with other
00013    programs, and to distribute those programs without any restriction
00014    coming from the use of this file. (The GNU Lesser General Public
00015    License restrictions do apply in other respects; for example, they
00016    cover modification of the file, and distribution when not linked
00017    into another program.)
00018 
00019    Note that people who make modified versions of this file are not
00020    obligated to grant this special exception for their modified
00021    versions; it is their choice whether to do so. The GNU Lesser
00022    General Public License gives permission to release a modified
00023    version without this exception; this exception also makes it
00024    possible to release a modified version which carries forward this
00025    exception.
00026 
00027    The GNU C Library is distributed in the hope that it will be useful,
00028    but WITHOUT ANY WARRANTY; without even the implied warranty of
00029    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00030    Lesser General Public License for more details.
00031 
00032    You should have received a copy of the GNU Lesser General Public
00033    License along with the GNU C Library; if not, write to the Free
00034    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00035    02111-1307 USA.  */
00036 
00037 /* This file is compiled into assembly code which is then munged by a sed
00038    script into two files: crti.s and crtn.s.
00039 
00040    * crti.s puts a function prologue at the beginning of the
00041    .init and .fini sections and defines global symbols for
00042    those addresses, so they can be called as functions.
00043 
00044    * crtn.s puts the corresponding function epilogues
00045    in the .init and .fini sections. */
00046 
00047 __asm__ ("\
00048 \n\
00049 #include \"defs.h\"\n\
00050 #define SHARED\n\
00051 \n\
00052 /*@HEADER_ENDS*/\n\
00053 \n\
00054 /*@TESTS_BEGIN*/\n\
00055 \n\
00056 /*@TESTS_END*/\n\
00057 \n\
00058 /*@_init_PROLOG_BEGINS*/\n\
00059        .section .init\n\
00060        .align 5\n\
00061        .global       _init\n\
00062        .type  _init,@function\n\
00063 _init:\n\
00064        mov.l  r12,@-r15\n\
00065        mov.l  r14,@-r15\n\
00066        sts.l  pr,@-r15\n\
00067 #ifdef SHARED\n\
00068        mova   .L22,r0\n\
00069        mov.l  .L22,r12\n\
00070        add    r0,r12\n\
00071        mova   .L23,r0\n\
00072        mov.l  .L23,r1\n\
00073        add    r0,r1\n\
00074 #else\n\
00075        mov.l  .L23,r1\n\
00076 #endif\n\
00077        jsr    @r1\n\
00078         mov   r15,r14\n\
00079        bra    1f\n\
00080         nop\n\
00081        .align 2\n\
00082 #ifdef SHARED\n\
00083 .L22:\n\
00084        .long  _GLOBAL_OFFSET_TABLE_\n\
00085 .L23:\n\
00086        .long  __gmon_start__@PLT\n\
00087 #else\n\
00088 .L23:\n\
00089        .long  __gmon_start__\n\
00090 #endif\n\
00091 1:\n\
00092        ALIGN\n\
00093        END_INIT\n\
00094 \n\
00095        \n\
00096 /*@_init_PROLOG_ENDS*/\n\
00097 \n\
00098 /*@_init_EPILOG_BEGINS*/\n\
00099        .section .init\n\
00100        mov    r14,r15\n\
00101        lds.l  @r15+,pr\n\
00102        mov.l  @r15+,r14\n\
00103        rts    \n\
00104        mov.l  @r15+,r12\n\
00105        END_INIT\n\
00106        .section .text\n\
00107        .align 5\n\
00108        .weak  __gmon_start__\n\
00109        .type  __gmon_start__,@function\n\
00110 __gmon_start__:\n\
00111        mov.l  r14,@-r15\n\
00112        mov    r15,r14\n\
00113        mov    r14,r15\n\
00114        rts    \n\
00115        mov.l  @r15+,r14\n\
00116        \n\
00117 /*@_init_EPILOG_ENDS*/\n\
00118 \n\
00119 /*@_fini_PROLOG_BEGINS*/\n\
00120        .section .fini\n\
00121        .align 5\n\
00122        .global       _fini\n\
00123        .type  _fini,@function\n\
00124 _fini:\n\
00125        mov.l  r12,@-r15\n\
00126        mov.l  r14,@-r15\n\
00127        sts.l  pr,@-r15\n\
00128 #ifdef SHARED\n\
00129        mova   .L27,r0\n\
00130        mov.l  .L27,r12\n\
00131        add    r0,r12\n\
00132 #endif\n\
00133        mov    r15,r14\n\
00134        ALIGN\n\
00135        END_FINI\n\
00136 #ifdef SHARED\n\
00137        bra    1f\n\
00138         nop\n\
00139        .align 2\n\
00140 .L27:\n\
00141        .long  _GLOBAL_OFFSET_TABLE_\n\
00142 #endif\n\
00143 1:\n\
00144 /*@_fini_PROLOG_ENDS*/\n\
00145 \n\
00146 /*@_fini_EPILOG_BEGINS*/\n\
00147        .section .fini\n\
00148        mov    r14,r15\n\
00149        lds.l  @r15+,pr\n\
00150        mov.l  @r15+,r14\n\
00151        rts    \n\
00152        mov.l  @r15+,r12\n\
00153 \n\
00154        END_FINI\n\
00155        \n\
00156 /*@_fini_EPILOG_ENDS*/\n\
00157 \n\
00158 /*@TRAILER_BEGINS*/\
00159 ");