OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / nptl / sysdeps / alpha / elf / pt-initfini.c
1 /* Special .init and .fini section support for Alpha.  NPTL version.
2    Copyright (C) 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 and/or
6    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    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 /* This file is compiled into assembly code which is then munged by a sed
20    script into two files: crti.s and crtn.s.
21
22    * crti.s puts a function prologue at the beginning of the .init and .fini
23    sections and defines global symbols for those addresses, so they can be
24    called as functions.
25
26    * crtn.s puts the corresponding function epilogues in the .init and .fini
27    sections.
28
29    This differs from what would be generated by the generic code in that
30    we save and restore the GP within the function.  In order for linker
31    relaxation to work, the value in the GP register on exit from a function
32    must be valid for the function entry point.  Normally, a function is
33    contained within one object file and this is not an issue, provided
34    that the function reloads the gp after making any function calls.
35    However, _init and _fini are constructed from pieces of many object
36    files, all of which may have different GP values.  So we must reload
37    the GP value from crti.o in crtn.o.  */
38
39 __asm__ ("                                              \n\
40 #include \"defs.h\"                                     \n\
41                                                         \n\
42 /*@HEADER_ENDS*/                                        \n\
43                                                         \n\
44 /*@_init_PROLOG_BEGINS*/                                \n\
45         .section .init, \"ax\", @progbits               \n\
46         .globl  _init                                   \n\
47         .type   _init,@function                         \n\
48         .usepv  _init,std                               \n\
49 _init:                                                  \n\
50         ldgp    $29, 0($27)                             \n\
51         subq    $30, 16, $30                            \n\
52         stq     $26, 0($30)                             \n\
53         stq     $29, 8($30)                             \n\
54         bsr     $26, __pthread_initialize_minimal_internal !samegp \n\
55         .align 3                                        \n\
56 /*@_init_PROLOG_ENDS*/                                  \n\
57                                                         \n\
58 /*@_init_EPILOG_BEGINS*/                                \n\
59         .section .init, \"ax\", @progbits               \n\
60         ldq     $26, 0($30)                             \n\
61         ldq     $29, 8($30)                             \n\
62         addq    $30, 16, $30                            \n\
63         ret                                             \n\
64 /*@_init_EPILOG_ENDS*/                                  \n\
65                                                         \n\
66 /*@_fini_PROLOG_BEGINS*/                                \n\
67         .section .fini, \"ax\", @progbits               \n\
68         .globl  _fini                                   \n\
69         .type   _fini,@function                         \n\
70         .usepv  _fini,std                               \n\
71 _fini:                                                  \n\
72         ldgp    $29, 0($27)                             \n\
73         subq    $30, 16, $30                            \n\
74         stq     $26, 0($30)                             \n\
75         stq     $29, 8($30)                             \n\
76         .align 3                                        \n\
77 /*@_fini_PROLOG_ENDS*/                                  \n\
78                                                         \n\
79 /*@_fini_EPILOG_BEGINS*/                                \n\
80         .section .fini, \"ax\", @progbits               \n\
81         ldq     $26, 0($30)                             \n\
82         ldq     $29, 8($30)                             \n\
83         addq    $30, 16, $30                            \n\
84         ret                                             \n\
85 /*@_fini_EPILOG_ENDS*/                                  \n\
86                                                         \n\
87 /*@TRAILER_BEGINS*/                                     \n\
88 ");