Back to index

glibc  2.9
pt-initfini.c
Go to the documentation of this file.
00001 /* Special .init and .fini section support for SH. NPTL version.
00002    Copyright (C) 2003 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
00006    and/or modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    In addition to the permissions in the GNU Library 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 Library 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    The GNU C Library is distributed in the hope that it will be
00020    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00021    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022    GNU Library General Public License for more details.
00023 
00024    You should have received a copy of the GNU Library General Public
00025    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00026    write to the Free Software Foundation, 59 Temple Place - Suite 330,
00027    Boston, MA 02111-1307, USA.  */
00028 
00029 /* This file is compiled into assembly code which is then munged by a sed
00030    script into two files: crti.s and crtn.s.
00031 
00032    * crti.s puts a function prologue at the beginning of the
00033    .init and .fini sections and defines global symbols for
00034    those addresses, so they can be called as functions.
00035 
00036    * crtn.s puts the corresponding function epilogues
00037    in the .init and .fini sections. */
00038 
00039 __asm__ ("\n\
00040 \n\
00041 #include \"defs.h\"\n\
00042 \n\
00043 /*@HEADER_ENDS*/\n\
00044 \n\
00045 /*@TESTS_BEGIN*/\n\
00046 \n\
00047 /*@TESTS_END*/\n\
00048 \n\
00049 /*@_init_PROLOG_BEGINS*/\n\
00050        .section .init\n\
00051        .align 5\n\
00052        .global       _init\n\
00053        .type  _init,@function\n\
00054 _init:\n\
00055        mov.l  r12,@-r15\n\
00056        mov.l  r14,@-r15\n\
00057        sts.l  pr,@-r15\n\
00058        mova   .L22,r0\n\
00059        mov.l  .L22,r12\n\
00060        add    r0,r12\n\
00061        mova   .L24,r0\n\
00062        mov.l  .L24,r1\n\
00063        add    r0,r1\n\
00064        jsr    @r1\n\
00065         nop\n\
00066        mova   .L23,r0\n\
00067        mov.l  .L23,r1\n\
00068        add    r0,r1\n\
00069        jsr    @r1\n\
00070         mov   r15,r14\n\
00071        bra    1f\n\
00072         nop\n\
00073        .align 2\n\
00074 .L22:\n\
00075        .long  _GLOBAL_OFFSET_TABLE_\n\
00076 .L23:\n\
00077        .long  __gmon_start__@PLT\n\
00078 .L24:\n\
00079        .long  __pthread_initialize_minimal_internal@PLT\n\
00080 1:\n\
00081        ALIGN\n\
00082        END_INIT\n\
00083 \n\
00084 /*@_init_PROLOG_ENDS*/\n\
00085 \n\
00086 /*@_init_EPILOG_BEGINS*/\n\
00087        .section .init\n\
00088        mov    r14,r15\n\
00089        lds.l  @r15+,pr\n\
00090        mov.l  @r15+,r14\n\
00091        rts    \n\
00092        mov.l  @r15+,r12\n\
00093        END_INIT\n\
00094        .section .text\n\
00095        .align 5\n\
00096        .weak  __gmon_start__\n\
00097        .type  __gmon_start__,@function\n\
00098 __gmon_start__:\n\
00099        mov.l  r14,@-r15\n\
00100        mov    r15,r14\n\
00101        mov    r14,r15\n\
00102        rts    \n\
00103        mov.l  @r15+,r14\n\
00104        \n\
00105 /*@_init_EPILOG_ENDS*/\n\
00106 \n\
00107 /*@_fini_PROLOG_BEGINS*/\n\
00108        .section .fini\n\
00109        .align 5\n\
00110        .global       _fini\n\
00111        .type  _fini,@function\n\
00112 _fini:\n\
00113        mov.l  r12,@-r15\n\
00114        mov.l  r14,@-r15\n\
00115        sts.l  pr,@-r15\n\
00116        mova   .L27,r0\n\
00117        mov.l  .L27,r12\n\
00118        add    r0,r12\n\
00119        mov    r15,r14\n\
00120        ALIGN\n\
00121        END_FINI\n\
00122        bra    1f\n\
00123         nop\n\
00124        .align 2\n\
00125 .L27:\n\
00126        .long  _GLOBAL_OFFSET_TABLE_\n\
00127 1:\n\
00128 /*@_fini_PROLOG_ENDS*/\n\
00129 \n\
00130 /*@_fini_EPILOG_BEGINS*/\n\
00131        .section .fini\n\
00132        mov    r14,r15\n\
00133        lds.l  @r15+,pr\n\
00134        mov.l  @r15+,r14\n\
00135        rts    \n\
00136        mov.l  @r15+,r12\n\
00137 \n\
00138        END_FINI\n\
00139        \n\
00140 /*@_fini_EPILOG_ENDS*/\n\
00141 \n\
00142 /*@TRAILER_BEGINS*/\n\
00143 ");