(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / sysdeps / unix / sysv / linux / ia64 / pt-initfini.c
blob85fd33f4a8d475dd626801d0ce3dbcb265ef0c77
1 /* Special .init and .fini section support for ia64. LinuxThreads version.
2 Copyright (C) 2000, 2001, 2002, 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
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.
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.)
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.
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. */
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.
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.
36 * crtn.s puts the corresponding function epilogues
37 in the .init and .fini sections. */
39 #include <stddef.h>
41 #ifdef HAVE_INITFINI_ARRAY
43 # define INIT_NEW_WAY \
44 ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal)\n"
45 # define INIT_OLD_WAY ""
46 #else
47 # define INIT_NEW_WAY ""
48 # define INIT_OLD_WAY \
49 "\n\
50 st8 [r12] = gp, -16\n\
51 br.call.sptk.many b0 = __pthread_initialize_minimal# ;;\n\
52 ;;\n\
53 adds r12 = 16, r12\n\
54 ;;\n\
55 ld8 gp = [r12]\n\
56 ;;\n"
57 #endif
59 __asm__ ("\n\
60 \n\
61 #include \"defs.h\"\n\
62 \n\
63 /*@HEADER_ENDS*/\n\
64 \n\
65 /*@_init_PROLOG_BEGINS*/\n"
66 INIT_NEW_WAY
67 ".section .init\n\
68 .align 16\n\
69 .global _init#\n\
70 .proc _init#\n\
71 _init:\n\
72 .prologue\n\
73 .save ar.pfs, r34\n\
74 alloc r34 = ar.pfs, 0, 3, 0, 0\n\
75 .vframe r32\n\
76 mov r32 = r12\n\
77 .save rp, r33\n\
78 mov r33 = b0\n\
79 .body\n\
80 adds r12 = -16, r12\n\
81 ;;\n"
82 INIT_OLD_WAY
83 ".endp _init#\n\
84 \n\
85 /*@_init_PROLOG_ENDS*/\n\
86 \n\
87 /*@_init_EPILOG_BEGINS*/\n\
88 .section .init\n\
89 .proc _init#\n\
90 .prologue\n\
91 .save ar.pfs, r34\n\
92 .vframe r32\n\
93 .save rp, r33\n\
94 .body\n\
95 mov r12 = r32\n\
96 mov ar.pfs = r34\n\
97 mov b0 = r33\n\
98 br.ret.sptk.many b0\n\
99 .endp _init#\n\
100 /*@_init_EPILOG_ENDS*/\n\
102 /*@_fini_PROLOG_BEGINS*/\n\
103 .section .fini\n\
104 .align 16\n\
105 .global _fini#\n\
106 .proc _fini#\n\
107 _fini:\n\
108 .prologue\n\
109 .save ar.pfs, r34\n\
110 alloc r34 = ar.pfs, 0, 3, 0, 0\n\
111 .vframe r32\n\
112 mov r32 = r12\n\
113 .save rp, r33\n\
114 mov r33 = b0\n\
115 .body\n\
116 adds r12 = -16, r12\n\
117 ;;\n\
118 .endp _fini#\n\
120 /*@_fini_PROLOG_ENDS*/\n\
122 /*@_fini_EPILOG_BEGINS*/\n\
123 .section .fini\n\
124 .proc _fini#\n\
125 .prologue\n\
126 .save ar.pfs, r34\n\
127 .vframe r32\n\
128 .save rp, r33\n\
129 .body\n\
130 mov r12 = r32\n\
131 mov ar.pfs = r34\n\
132 mov b0 = r33\n\
133 br.ret.sptk.many b0\n\
134 .endp _fini#\n\
136 /*@_fini_EPILOG_ENDS*/\n\
138 /*@TRAILER_BEGINS*/\n\
139 .weak __gmon_start__#\n\