Update.
[glibc.git] / sysdeps / x86_64 / elf / initfini.c
blobb0638aca2f01a024411ef391546fa798613d08ea
1 /* Special .init and .fini section support for x86-64.
2 Copyright (C) 2001 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 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 GNU 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 useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 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; if not, write to the Free
26 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 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 __asm__ ("\n\
40 #include \"defs.h\"\n\
41 \n\
42 /*@HEADER_ENDS*/\n\
43 \n\
44 /*@_init_PROLOG_BEGINS*/\n\
45 .align 4\n\
46 .type call_gmon_start,@function\n\
47 call_gmon_start:\n\
48 subq $8, %rsp\n\
49 movq __gmon_start__@GOTPCREL(%rip), %rax\n\
50 testq %rax, %rax\n\
51 je .L22\n\
52 call *%rax\n\
53 .L22:\n\
54 addq $8, %rsp\n\
55 ret\n\
56 \n\
57 .section .init\n\
58 .align 4\n\
59 .globl _init\n\
60 .type _init,@function\n\
61 _init:\n\
62 subq $8, %rsp\n\
63 /* call call_gmon_start */\n\
64 ALIGN\n\
65 END_INIT\n\
66 \n\
67 /*@_init_PROLOG_ENDS*/\n\
68 \n\
69 /*@_init_EPILOG_BEGINS*/\n\
70 .section .init\n\
71 addq $8, %rsp\n\
72 ret\n\
73 END_INIT\n\
74 \n\
75 /*@_init_EPILOG_ENDS*/\n\
76 \n\
77 /*@_fini_PROLOG_BEGINS*/\n\
78 .section .fini\n\
79 .align 4\n\
80 .globl _fini\n\
81 .type _fini,@function\n\
82 _fini:\n\
83 subq $8, %rsp\n\
84 ALIGN\n\
85 END_FINI\n\
86 \n\
87 /*@_fini_PROLOG_ENDS*/\n\
88 call i_am_not_a_leaf@PLT\n\
89 \n\
90 /*@_fini_EPILOG_BEGINS*/\n\
91 .section .fini\n\
92 addq $8, %rsp\n\
93 ret\n\
94 END_FINI\n\
95 \n\
96 /*@_fini_EPILOG_ENDS*/\n\
97 \n\
98 /*@TRAILER_BEGINS*/\n\
99 .weak __gmon_start__\n\