chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / ports / sysdeps / unix / sysv / linux / hppa / nptl / pt-initfini.c
1 /* Special .init and .fini section support for HPPA.  NPTL version.
2    Copyright (C) 2005 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    write to the Free Software Foundation, 59 Temple Place - Suite 330,
27    Boston, MA 02111-1307, USA.  */
28
29 /* This file is compiled into assembly code which is then munged by a sed
30    script into two files: crti.s and crtn.s.
31
32    * crti.s puts a function prologue at the beginning of the
33    .init and .fini sections and defines global symbols for
34    those addresses, so they can be called as functions.
35
36    * crtn.s puts the corresponding function epilogues
37    in the .init and .fini sections. */
38
39 /* If we use the standard C version, the linkage table pointer won't
40    be properly preserved due to the splitting up of function prologues
41    and epilogues.  Therefore we write these in assembly to make sure
42    they do the right thing.  */
43
44 __asm__ (
45 "#include \"defs.h\"\n"
46 "\n"
47 "/*@HEADER_ENDS*/\n"
48 "\n"
49 "/*@_init_PROLOG_BEGINS*/\n"
50 "       .section .init\n"
51 "       .align 4\n"
52 "       .globl _init\n"
53 "       .type _init,@function\n"
54 "_init:\n"
55 "       stw     %rp,-20(%sp)\n"
56 "       stwm    %r4,64(%sp)\n"
57 "       stw     %r19,-32(%sp)\n"
58 "       bl      __pthread_initialize_minimal_internal,%rp\n"
59 "       copy    %r19,%r4        /* delay slot */\n"
60 "       copy    %r4,%r19\n"
61 "/*@_init_PROLOG_ENDS*/\n"
62 "\n"
63 "/*@_init_EPILOG_BEGINS*/\n"
64 "/* Here is the tail end of _init.  */\n"
65 "       .section .init\n"
66 "       ldw     -84(%sp),%rp\n"
67 "       copy    %r4,%r19\n"
68 "       bv      %r0(%rp)\n"
69 "_end_init:\n"
70 "       ldwm    -64(%sp),%r4\n"
71 "\n"
72 "/* Our very own unwind info, because the assembler can't handle\n"
73 "   functions split into two or more pieces.  */\n"
74 "       .section .PARISC.unwind,\"a\",@progbits\n"
75 "       .extern _init\n"
76 "       .word   _init, _end_init\n"
77 "       .byte   0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
78 "\n"
79 "/*@_init_EPILOG_ENDS*/\n"
80 "\n"
81 "/*@_fini_PROLOG_BEGINS*/\n"
82 "       .section .fini\n"
83 "       .align 4\n"
84 "       .globl _fini\n"
85 "       .type _fini,@function\n"
86 "_fini:\n"
87 "       stw     %rp,-20(%sp)\n"
88 "       stwm    %r4,64(%sp)\n"
89 "       stw     %r19,-32(%sp)\n"
90 "       copy    %r19,%r4\n"
91 "/*@_fini_PROLOG_ENDS*/\n"
92 "\n"
93 "/*@_fini_EPILOG_BEGINS*/\n"
94 "       .section .fini\n"
95 "       ldw     -84(%sp),%rp\n"
96 "       copy    %r4,%r19\n"
97 "       bv      %r0(%rp)\n"
98 "_end_fini:\n"
99 "       ldwm    -64(%sp),%r4\n"
100 "\n"
101 "       .section .PARISC.unwind,\"a\",@progbits\n"
102 "       .extern _fini\n"
103 "       .word   _fini, _end_fini\n"
104 "       .byte   0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
105 "\n"
106 "/*@_fini_EPILOG_ENDS*/\n"
107 "\n"
108 "/*@TRAILER_BEGINS*/\n"
109 );