Back to index

glibc  2.9
pt-initfini.c
Go to the documentation of this file.
00001 /* Special .init and .fini section support for ia64. LinuxThreads version.
00002    Copyright (C) 2000, 2001, 2002, 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 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 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    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 Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser 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 #include <stddef.h>
00040 
00041 #ifdef HAVE_INITFINI_ARRAY
00042 
00043 # define INIT_NEW_WAY \
00044     ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal)\n"
00045 # define INIT_OLD_WAY ""
00046 #else
00047 # define INIT_NEW_WAY ""
00048 # define INIT_OLD_WAY \
00049        "\n\
00050        st8 [r12] = gp, -16\n\
00051        br.call.sptk.many b0 = __pthread_initialize_minimal# ;;\n\
00052        ;;\n\
00053        adds r12 = 16, r12\n\
00054        ;;\n\
00055        ld8 gp = [r12]\n\
00056        ;;\n"
00057 #endif
00058 
00059 __asm__ ("\n\
00060 \n\
00061 #include \"defs.h\"\n\
00062 \n\
00063 /*@HEADER_ENDS*/\n\
00064 \n\
00065 /*@_init_PROLOG_BEGINS*/\n"
00066        INIT_NEW_WAY
00067        ".section .init\n\
00068        .align 16\n\
00069        .global _init#\n\
00070        .proc _init#\n\
00071 _init:\n\
00072        .prologue\n\
00073        .save ar.pfs, r34\n\
00074        alloc r34 = ar.pfs, 0, 3, 0, 0\n\
00075        .vframe r32\n\
00076        mov r32 = r12\n\
00077        .save rp, r33\n\
00078        mov r33 = b0\n\
00079        .body\n\
00080        adds r12 = -16, r12\n\
00081        ;;\n"
00082        INIT_OLD_WAY
00083        ".endp _init#\n\
00084 \n\
00085 /*@_init_PROLOG_ENDS*/\n\
00086 \n\
00087 /*@_init_EPILOG_BEGINS*/\n\
00088        .section .init\n\
00089        .proc _init#\n\
00090 _init:\n\
00091        .prologue\n\
00092        .save ar.pfs, r34\n\
00093        .vframe r32\n\
00094        .save rp, r33\n\
00095        .body\n\
00096        mov r12 = r32\n\
00097        mov ar.pfs = r34\n\
00098        mov b0 = r33\n\
00099        br.ret.sptk.many b0\n\
00100        .endp _init#\n\
00101 /*@_init_EPILOG_ENDS*/\n\
00102 \n\
00103 /*@_fini_PROLOG_BEGINS*/\n\
00104        .section .fini\n\
00105        .align 16\n\
00106        .global _fini#\n\
00107        .proc _fini#\n\
00108 _fini:\n\
00109        .prologue\n\
00110        .save ar.pfs, r34\n\
00111        alloc r34 = ar.pfs, 0, 3, 0, 0\n\
00112        .vframe r32\n\
00113        mov r32 = r12\n\
00114        .save rp, r33\n\
00115        mov r33 = b0\n\
00116        .body\n\
00117        adds r12 = -16, r12\n\
00118        ;;\n\
00119        .endp _fini#\n\
00120 \n\
00121 /*@_fini_PROLOG_ENDS*/\n\
00122 \n\
00123 /*@_fini_EPILOG_BEGINS*/\n\
00124        .section .fini\n\
00125        .proc _fini#\n\
00126 _fini:\n\
00127        .prologue\n\
00128        .save ar.pfs, r34\n\
00129        .vframe r32\n\
00130        .save rp, r33\n\
00131        .body\n\
00132        mov r12 = r32\n\
00133        mov ar.pfs = r34\n\
00134        mov b0 = r33\n\
00135        br.ret.sptk.many b0\n\
00136        .endp _fini#\n\
00137 \n\
00138 /*@_fini_EPILOG_ENDS*/\n\
00139 \n\
00140 /*@TRAILER_BEGINS*/\n\
00141        .weak  __gmon_start__#\n\
00142 ");