2.9
[glibc/nacl-glibc.git] / sysdeps / x86_64 / elf / initfini.c
blob30161d52eddd6f49b1913d96523cb690d0a76285
1 /* Special .init and .fini section support for x86-64.
2 Copyright (C) 2001, 2002 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 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, write to the Free
34 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
35 02111-1307 USA. */
37 /* This file is compiled into assembly code which is then munged by a sed
38 script into two files: crti.s and crtn.s.
40 * crti.s puts a function prologue at the beginning of the
41 .init and .fini sections and defines global symbols for
42 those addresses, so they can be called as functions.
44 * crtn.s puts the corresponding function epilogues
45 in the .init and .fini sections. */
47 __asm__ ("\n\
48 #include \"defs.h\"\n\
49 \n\
50 /*@HEADER_ENDS*/\n\
51 \n\
52 /*@_init_PROLOG_BEGINS*/\n\
53 .align 4\n\
54 .type call_gmon_start,@function\n\
55 call_gmon_start:\n\
56 subq $8, %rsp\n\
57 movq __gmon_start__@GOTPCREL(%rip), %rax\n\
58 testq %rax, %rax\n\
59 je .L22\n\
60 call *%rax\n\
61 .L22:\n\
62 addq $8, %rsp\n\
63 ret\n\
64 \n\
65 .section .init\n\
66 .align 4\n\
67 .globl _init\n\
68 .type _init,@function\n\
69 _init:\n\
70 subq $8, %rsp\n\
71 call call_gmon_start\n\
72 ALIGN\n\
73 END_INIT\n\
74 \n\
75 /*@_init_PROLOG_ENDS*/\n\
76 \n\
77 /*@_init_EPILOG_BEGINS*/\n\
78 .section .init\n\
79 addq $8, %rsp\n\
80 ret\n\
81 END_INIT\n\
82 \n\
83 /*@_init_EPILOG_ENDS*/\n\
84 \n\
85 /*@_fini_PROLOG_BEGINS*/\n\
86 .section .fini\n\
87 .align 4\n\
88 .globl _fini\n\
89 .type _fini,@function\n\
90 _fini:\n\
91 subq $8, %rsp\n\
92 ALIGN\n\
93 END_FINI\n\
94 \n\
95 /*@_fini_PROLOG_ENDS*/\n\
96 call i_am_not_a_leaf@PLT\n\
97 \n\
98 /*@_fini_EPILOG_BEGINS*/\n\
99 .section .fini\n\
100 addq $8, %rsp\n\
101 ret\n\
102 END_FINI\n\
104 /*@_fini_EPILOG_ENDS*/\n\
106 /*@TRAILER_BEGINS*/\n\
107 .weak __gmon_start__\n\