OSDN Git Service

82c97c352a95d335e84bca3010b10196ff35bd82
[uclinux-h8/uClibc.git] / libpthread / nptl / sysdeps / unix / sysv / linux / sh / pt-initfini.c
1 /* Special .init and .fini section support for SH.  NPTL version.
2    Copyright (C) 2003, 2009 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 Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9
10    In addition to the permissions in the GNU Library 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 Library 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 Library General Public License for more details.
23
24    You should have received a copy of the GNU Library 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 __asm__ ("\n\
40 \n\
41 #include \"defs.h\"\n\
42 \n\
43 /*@HEADER_ENDS*/\n\
44 \n\
45 /*@TESTS_BEGIN*/\n\
46 \n\
47 /*@TESTS_END*/\n\
48 \n\
49 /*@_init_PROLOG_BEGINS*/\n\
50         .section .init\n\
51         .align 5\n\
52         .global _init\n\
53         .type   _init,@function\n\
54 _init:\n\
55         mov.l   r12,@-r15\n\
56         mov.l   r14,@-r15\n\
57         sts.l   pr,@-r15\n\
58         mova    .L22,r0\n\
59         mov.l   .L22,r12\n\
60         add     r0,r12\n\
61         mova    .L24,r0\n\
62         mov.l   .L24,r1\n\
63         add     r0,r1\n\
64         jsr     @r1\n\
65          mov    r15,r14\n\
66         bra     1f\n\
67          nop\n\
68         .align 2\n\
69 .L22:\n\
70         .long   _GLOBAL_OFFSET_TABLE_\n\
71 .L24:\n\
72         .long   __pthread_initialize_minimal_internal@PLT\n\
73 1:\n\
74         ALIGN\n\
75         END_INIT\n\
76 \n\
77 /*@_init_PROLOG_ENDS*/\n\
78 \n\
79 /*@_init_EPILOG_BEGINS*/\n\
80         .section .init\n\
81         mov     r14,r15\n\
82         lds.l   @r15+,pr\n\
83         mov.l   @r15+,r14\n\
84         rts     \n\
85         mov.l   @r15+,r12\n\
86         END_INIT\n\
87         \n\
88 /*@_init_EPILOG_ENDS*/\n\
89 \n\
90 /*@_fini_PROLOG_BEGINS*/\n\
91         .section .fini\n\
92         .align 5\n\
93         .global _fini\n\
94         .type   _fini,@function\n\
95 _fini:\n\
96         mov.l   r12,@-r15\n\
97         mov.l   r14,@-r15\n\
98         sts.l   pr,@-r15\n\
99         mova    .L27,r0\n\
100         mov.l   .L27,r12\n\
101         add     r0,r12\n\
102         mov     r15,r14\n\
103         ALIGN\n\
104         END_FINI\n\
105         bra     1f\n\
106          nop\n\
107         .align  2\n\
108 .L27:\n\
109         .long   _GLOBAL_OFFSET_TABLE_\n\
110 1:\n\
111 /*@_fini_PROLOG_ENDS*/\n\
112 \n\
113 /*@_fini_EPILOG_BEGINS*/\n\
114         .section .fini\n\
115         mov     r14,r15\n\
116         lds.l   @r15+,pr\n\
117         mov.l   @r15+,r14\n\
118         rts     \n\
119         mov.l   @r15+,r12\n\
120 \n\
121         END_FINI\n\
122         \n\
123 /*@_fini_EPILOG_ENDS*/\n\
124 \n\
125 /*@TRAILER_BEGINS*/\n\
126 ");