OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / linuxthreads / sysdeps / unix / sysv / linux / hppa / pt-initfini.c
1 /* Special .init and .fini section support for HPPA.  Linuxthreads version.
2    Copyright (C) 2001, 2003 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it
6    and/or modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    In addition to the permissions in the GNU Lesser General Public
11    License, the Free Software Foundation gives you unlimited
12    permission to link the compiled version of this file with other
13    programs, and to distribute those programs without any restriction
14    coming from the use of this file.  (The Lesser General Public
15    License restrictions do apply in other respects; for example, they
16    cover modification of the file, and distribution when not linked
17    into another program.)
18
19    The GNU C Library is distributed in the hope that it will be
20    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    GNU Lesser General Public License for more details.
23
24    You should have received a copy of the GNU Lesser General Public
25    License along with the GNU C Library; see the file COPYING.LIB.  If not,
26    see <http://www.gnu.org/licenses/>.  */
27
28 /* This file is compiled into assembly code which is then munged by a sed
29    script into two files: crti.s and crtn.s.
30
31    * crti.s puts a function prologue at the beginning of the
32    .init and .fini sections and defines global symbols for
33    those addresses, so they can be called as functions.
34
35    * crtn.s puts the corresponding function epilogues
36    in the .init and .fini sections. */
37
38 /* If we use the standard C version, the linkage table pointer won't
39    be properly preserved due to the splitting up of function prologues
40    and epilogues.  Therefore we write these in assembly to make sure
41    they do the right thing.  */
42
43 __asm__ (
44 "#include \"defs.h\"\n"
45 "\n"
46 "/*@HEADER_ENDS*/\n"
47 "\n"
48 "/*@_init_PROLOG_BEGINS*/\n"
49 "       .section .init\n"
50 "       .align 4\n"
51 "       .globl _init\n"
52 "       .type _init,@function\n"
53 "_init:\n"
54 "       stw     %rp,-20(%sp)\n"
55 "       stwm    %r4,64(%sp)\n"
56 "       stw     %r19,-32(%sp)\n"
57 "       bl      __pthread_initialize_minimal,%rp\n"
58 "       copy    %r19,%r4        /* delay slot */\n"
59 "       copy    %r4,%r19\n"
60 "/*@_init_PROLOG_ENDS*/\n"
61 "\n"
62 "/*@_init_EPILOG_BEGINS*/\n"
63 "/* Here is the tail end of _init.  */\n"
64 "       .section .init\n"
65 "       ldw     -84(%sp),%rp\n"
66 "       copy    %r4,%r19\n"
67 "       bv      %r0(%rp)\n"
68 "_end_init:\n"
69 "       ldwm    -64(%sp),%r4\n"
70 "\n"
71 "/* Our very own unwind info, because the assembler can't handle\n"
72 "   functions split into two or more pieces.  */\n"
73 "       .section .PARISC.unwind,\"a\",@progbits\n"
74 "       .extern _init\n"
75 "       .word   _init, _end_init\n"
76 "       .byte   0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
77 "\n"
78 "/*@_init_EPILOG_ENDS*/\n"
79 "\n"
80 "/*@_fini_PROLOG_BEGINS*/\n"
81 "       .section .fini\n"
82 "       .align 4\n"
83 "       .globl _fini\n"
84 "       .type _fini,@function\n"
85 "_fini:\n"
86 "       stw     %rp,-20(%sp)\n"
87 "       stwm    %r4,64(%sp)\n"
88 "       stw     %r19,-32(%sp)\n"
89 "       copy    %r19,%r4\n"
90 "/*@_fini_PROLOG_ENDS*/\n"
91 "\n"
92 "/*@_fini_EPILOG_BEGINS*/\n"
93 "       .section .fini\n"
94 "       ldw     -84(%sp),%rp\n"
95 "       copy    %r4,%r19\n"
96 "       bv      %r0(%rp)\n"
97 "_end_fini:\n"
98 "       ldwm    -64(%sp),%r4\n"
99 "\n"
100 "       .section .PARISC.unwind,\"a\",@progbits\n"
101 "       .extern _fini\n"
102 "       .word   _fini, _end_fini\n"
103 "       .byte   0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
104 "\n"
105 "/*@_fini_EPILOG_ENDS*/\n"
106 "\n"
107 "/*@TRAILER_BEGINS*/\n"
108 );