Back to index

glibc  2.9
pt-initfini.c
Go to the documentation of this file.
00001 /* Special .init and .fini section support for HPPA.  NPTL version.
00002    Copyright (C) 2005 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 /* If we use the standard C version, the linkage table pointer won't
00040    be properly preserved due to the splitting up of function prologues
00041    and epilogues.  Therefore we write these in assembly to make sure
00042    they do the right thing.  */
00043 
00044 __asm__ (
00045 "#include \"defs.h\"\n"
00046 "\n"
00047 "/*@HEADER_ENDS*/\n"
00048 "\n"
00049 "/*@_init_PROLOG_BEGINS*/\n"
00050 "      .section .init\n"
00051 "      .align 4\n"
00052 "      .globl _init\n"
00053 "      .type _init,@function\n"
00054 "_init:\n"
00055 "      stw    %rp,-20(%sp)\n"
00056 "      stwm   %r4,64(%sp)\n"
00057 "      stw    %r19,-32(%sp)\n"
00058 "      bl     __pthread_initialize_minimal_internal,%rp\n"
00059 "      copy   %r19,%r4      /* delay slot */\n"
00060 "      copy   %r4,%r19\n"
00061 "/*@_init_PROLOG_ENDS*/\n"
00062 "\n"
00063 "/*@_init_EPILOG_BEGINS*/\n"
00064 "/* Here is the tail end of _init.  */\n"
00065 "      .section .init\n"
00066 "      ldw    -84(%sp),%rp\n"
00067 "      copy   %r4,%r19\n"
00068 "      bv     %r0(%rp)\n"
00069 "_end_init:\n"
00070 "      ldwm   -64(%sp),%r4\n"
00071 "\n"
00072 "/* Our very own unwind info, because the assembler can't handle\n"
00073 "   functions split into two or more pieces.  */\n"
00074 "      .section .PARISC.unwind,\"a\",@progbits\n"
00075 "      .extern _init\n"
00076 "      .word  _init, _end_init\n"
00077 "      .byte  0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
00078 "\n"
00079 "/*@_init_EPILOG_ENDS*/\n"
00080 "\n"
00081 "/*@_fini_PROLOG_BEGINS*/\n"
00082 "      .section .fini\n"
00083 "      .align 4\n"
00084 "      .globl _fini\n"
00085 "      .type _fini,@function\n"
00086 "_fini:\n"
00087 "      stw    %rp,-20(%sp)\n"
00088 "      stwm   %r4,64(%sp)\n"
00089 "      stw    %r19,-32(%sp)\n"
00090 "      copy   %r19,%r4\n"
00091 "/*@_fini_PROLOG_ENDS*/\n"
00092 "\n"
00093 "/*@_fini_EPILOG_BEGINS*/\n"
00094 "      .section .fini\n"
00095 "      ldw    -84(%sp),%rp\n"
00096 "      copy   %r4,%r19\n"
00097 "      bv     %r0(%rp)\n"
00098 "_end_fini:\n"
00099 "      ldwm   -64(%sp),%r4\n"
00100 "\n"
00101 "      .section .PARISC.unwind,\"a\",@progbits\n"
00102 "      .extern _fini\n"
00103 "      .word  _fini, _end_fini\n"
00104 "      .byte  0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
00105 "\n"
00106 "/*@_fini_EPILOG_ENDS*/\n"
00107 "\n"
00108 "/*@TRAILER_BEGINS*/\n"
00109 );