2.9
[glibc/nacl-glibc.git] / nptl / sysdeps / alpha / elf / pt-initfini.c
blobba2e419d61a4e9c214b4cff94f1b2a34bd8f7741
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.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 /* This file is compiled into assembly code which is then munged by a sed
21 script into two files: crti.s and crtn.s.
23 * crti.s puts a function prologue at the beginning of the .init and .fini
24 sections and defines global symbols for those addresses, so they can be
25 called as functions.
27 * crtn.s puts the corresponding function epilogues in the .init and .fini
28 sections.
30 This differs from what would be generated by the generic code in that
31 we save and restore the GP within the function. In order for linker
32 relaxation to work, the value in the GP register on exit from a function
33 must be valid for the function entry point. Normally, a function is
34 contained within one object file and this is not an issue, provided
35 that the function reloads the gp after making any function calls.
36 However, _init and _fini are constructed from pieces of many object
37 files, all of which may have different GP values. So we must reload
38 the GP value from crti.o in crtn.o. */
40 __asm__ (" \n\
41 #include \"defs.h\" \n\
42 \n\
43 /*@HEADER_ENDS*/ \n\
44 \n\
45 /*@_init_PROLOG_BEGINS*/ \n\
46 .section .init, \"ax\", @progbits \n\
47 .globl _init \n\
48 .type _init,@function \n\
49 .usepv _init,std \n\
50 _init: \n\
51 ldgp $29, 0($27) \n\
52 subq $30, 16, $30 \n\
53 stq $26, 0($30) \n\
54 stq $29, 8($30) \n\
55 bsr $26, __pthread_initialize_minimal_internal !samegp \n\
56 .align 3 \n\
57 /*@_init_PROLOG_ENDS*/ \n\
58 \n\
59 /*@_init_EPILOG_BEGINS*/ \n\
60 .section .init, \"ax\", @progbits \n\
61 ldq $26, 0($30) \n\
62 ldq $29, 8($30) \n\
63 addq $30, 16, $30 \n\
64 ret \n\
65 /*@_init_EPILOG_ENDS*/ \n\
66 \n\
67 /*@_fini_PROLOG_BEGINS*/ \n\
68 .section .fini, \"ax\", @progbits \n\
69 .globl _fini \n\
70 .type _fini,@function \n\
71 .usepv _fini,std \n\
72 _fini: \n\
73 ldgp $29, 0($27) \n\
74 subq $30, 16, $30 \n\
75 stq $26, 0($30) \n\
76 stq $29, 8($30) \n\
77 .align 3 \n\
78 /*@_fini_PROLOG_ENDS*/ \n\
79 \n\
80 /*@_fini_EPILOG_BEGINS*/ \n\
81 .section .fini, \"ax\", @progbits \n\
82 ldq $26, 0($30) \n\
83 ldq $29, 8($30) \n\
84 addq $30, 16, $30 \n\
85 ret \n\
86 /*@_fini_EPILOG_ENDS*/ \n\
87 \n\
88 /*@TRAILER_BEGINS*/ \n\
89 ");