authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-20 17:16:36-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-20 20:59:52-08:00
logf5485a52bcd7495fb2be234695b4cea809f60581
treea43a6f12a362495e85e9a37bf59e25e48aa97f8b
parent2391c460b1c137e44c8e0c092a2401b2676e2629

reject crti.o/crtn.o, embrace the future

crti.o/crtn.o is a legacy strategy for calling constructor functions upon object loading that has been superseded by the init_array/fini_array mechanism. Zig code depends on neither, since the language intentionally has no way to initialize data at runtime, but alas the Zig linker still must support this feature since popular languages depend on it. Anyway, the way it works is that crti.o has the machine code prelude of two functions called _init and _fini, each in their own section with the respective name. crtn.o has the machine code instructions comprising the exitlude for each function. In between, objects use the .init and .fini link section to populate the function body. This function is then expected to be called upon object initialization and deinitialization. This mechanism is depended on by libc, for example musl and glibc, but only for older ISAs. By the time the libcs gained support for newer ISAs, they had moved on to the init_array/fini_array mechanism instead. For the Zig linker, we are trying to move the linker towards order-independent objects which is incompatible with the legacy crti/crtn mechanism. Therefore, this commit drops support entirely for crti/crtn mechanism, which is necessary since the other commits in this branch make it nondeterministic in which order the libc objects and the other link inputs are sent to the linker. The linker is still expected to produce a deterministic output, however, by ignoring object input order for the purposes of symbol resolution.

70 files changed, 7 insertions(+), 3191 deletions(-)

lib/libc/glibc/sysdeps/aarch64/crti.S deleted-103
...@@ -1,103 +0,0 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37/* crti.S puts a function prologue at the beginning of the .init and
38 .fini sections and defines global symbols for those addresses, so
39 they can be called as functions. The symbols _init and _fini are
40 magic and cause the linker to emit DT_INIT and DT_FINI. */
41
42#include <sysdep.h>
43#include <libc-symbols.h>
44
45#ifndef PREINIT_FUNCTION
46# define PREINIT_FUNCTION __gmon_start__
47#endif
48
49#ifndef PREINIT_FUNCTION_WEAK
50# define PREINIT_FUNCTION_WEAK 1
51#endif
52
53#if PREINIT_FUNCTION_WEAK
54 weak_extern (PREINIT_FUNCTION)
55#else
56 .hidden PREINIT_FUNCTION
57#endif
58
59#if PREINIT_FUNCTION_WEAK
60 .align 2
61 .type call_weak_fn, %function
62call_weak_fn:
63 adrp x0, :got:PREINIT_FUNCTION
64 ldr PTR_REG (0), [x0, #:got_lo12:PREINIT_FUNCTION]
65 cbz x0, 1f
66 b PREINIT_FUNCTION
671:
68 RET
69 .size call_weak_fn, .-call_weak_fn
70#endif
71
72 .section .init,"ax",%progbits
73 .align 2
74 .global _init
75 .hidden _init
76 .type _init, %function
77_init:
78#if HAVE_AARCH64_PAC_RET
79 PACIASP
80#else
81 BTI_C
82#endif
83 stp x29, x30, [sp, -16]!
84 mov x29, sp
85#if PREINIT_FUNCTION_WEAK
86 bl call_weak_fn
87#else
88 bl PREINIT_FUNCTION
89#endif
90
91 .section .fini,"ax",%progbits
92 .align 2
93 .global _fini
94 .hidden _fini
95 .type _fini, %function
96_fini:
97#if HAVE_AARCH64_PAC_RET
98 PACIASP
99#else
100 BTI_C
101#endif
102 stp x29, x30, [sp, -16]!
103 mov x29, sp
lib/libc/glibc/sysdeps/aarch64/crtn.S deleted-54
...@@ -1,54 +0,0 @@
1/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2024 Free Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 In addition to the permissions in the GNU Lesser General Public
12 License, the Free Software Foundation gives you unlimited
13 permission to link the compiled version of this file with other
14 programs, and to distribute those programs without any restriction
15 coming from the use of this file. (The GNU Lesser General Public
16 License restrictions do apply in other respects; for example, they
17 cover modification of the file, and distribution when not linked
18 into another program.)
19
20 Note that people who make modified versions of this file are not
21 obligated to grant this special exception for their modified
22 versions; it is their choice whether to do so. The GNU Lesser
23 General Public License gives permission to release a modified
24 version without this exception; this exception also makes it
25 possible to release a modified version which carries forward this
26 exception.
27
28 The GNU C Library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with the GNU C Library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37/* crtn.S puts function epilogues in the .init and .fini sections
38 corresponding to the prologues in crti.S. */
39
40#include <sysdep.h>
41
42 .section .init,"ax",%progbits
43 ldp x29, x30, [sp], 16
44#if HAVE_AARCH64_PAC_RET
45 AUTIASP
46#endif
47 RET
48
49 .section .fini,"ax",%progbits
50 ldp x29, x30, [sp], 16
51#if HAVE_AARCH64_PAC_RET
52 AUTIASP
53#endif
54 RET
lib/libc/glibc/sysdeps/alpha/crti.S deleted-101
...@@ -1,101 +0,0 @@
1/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI.
40
41 This differs from what would be generated for ordinary code in that
42 we save and restore the GP within the function. In order for linker
43 relaxation to work, the value in the GP register on exit from a function
44 must be valid for the function entry point. Normally, a function is
45 contained within one object file and this is not an issue, provided
46 that the function reloads the gp after making any function calls.
47 However, _init and _fini are constructed from pieces of many object
48 files, all of which may have different GP values. So we must reload
49 the GP value from crti.o in crtn.o. */
50
51#include <libc-symbols.h>
52#include <sysdep.h>
53
54#ifndef PREINIT_FUNCTION
55# define PREINIT_FUNCTION __gmon_start__
56#endif
57
58#ifndef PREINIT_FUNCTION_WEAK
59# define PREINIT_FUNCTION_WEAK 1
60#endif
61
62#if PREINIT_FUNCTION_WEAK
63 weak_extern (PREINIT_FUNCTION)
64#else
65 .hidden PREINIT_FUNCTION
66#endif
67
68 .section .init, "ax", @progbits
69 .globl _init
70 .hidden _init
71 .type _init, @function
72 .usepv _init, std
73_init:
74 ldgp $29, 0($27)
75 subq $30, 16, $30
76#if PREINIT_FUNCTION_WEAK
77 lda $27, PREINIT_FUNCTION
78#endif
79 stq $26, 0($30)
80 stq $29, 8($30)
81#if PREINIT_FUNCTION_WEAK
82 beq $27, 1f
83 jsr $26, ($27), PREINIT_FUNCTION
84 ldq $29, 8($30)
851:
86#else
87 bsr $26, PREINIT_FUNCTION !samegp
88#endif
89 .p2align 3
90
91 .section .fini, "ax", @progbits
92 .globl _fini
93 .hidden _fini
94 .type _fini,@function
95 .usepv _fini,std
96_fini:
97 ldgp $29, 0($27)
98 subq $30, 16, $30
99 stq $26, 0($30)
100 stq $29, 8($30)
101 .p2align 3
lib/libc/glibc/sysdeps/alpha/crtn.S deleted-49
...@@ -1,49 +0,0 @@
1/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init, "ax", @progbits
40 ldq $26, 0($30)
41 ldq $29, 8($30)
42 addq $30, 16, $30
43 ret
44
45 .section .fini, "ax", @progbits
46 ldq $26, 0($30)
47 ldq $29, 8($30)
48 addq $30, 16, $30
49 ret
lib/libc/glibc/sysdeps/arm/crti.S deleted-97
...@@ -1,97 +0,0 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41/* Always build .init and .fini sections in ARM mode. */
42#define NO_THUMB
43#include <libc-symbols.h>
44#include <sysdep.h>
45
46#ifndef PREINIT_FUNCTION
47# define PREINIT_FUNCTION __gmon_start__
48#endif
49
50#ifndef PREINIT_FUNCTION_WEAK
51# define PREINIT_FUNCTION_WEAK 1
52#endif
53
54#if PREINIT_FUNCTION_WEAK
55 weak_extern (PREINIT_FUNCTION)
56#else
57 .hidden PREINIT_FUNCTION
58#endif
59
60#if PREINIT_FUNCTION_WEAK
61 .p2align 2
62 .type call_weak_fn, %function
63call_weak_fn:
64 ldr r3, .LGOT
65 ldr r2, .LGOT+4
66.LPIC:
67 add r3, pc, r3
68 ldr r2, [r3, r2]
69 cmp r2, #0
70 bxeq lr
71 b PREINIT_FUNCTION
72 .p2align 2
73.LGOT:
74 .word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
75 .word PREINIT_FUNCTION(GOT)
76#endif
77
78 .section .init,"ax",%progbits
79 .p2align 2
80 .globl _init
81 .hidden _init
82 .type _init, %function
83_init:
84 push {r3, lr}
85#if PREINIT_FUNCTION_WEAK
86 bl call_weak_fn
87#else
88 bl PREINIT_FUNCTION
89#endif
90
91 .section .fini,"ax",%progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, %function
96_fini:
97 push {r3, lr}
lib/libc/glibc/sysdeps/arm/crtn.S deleted-57
...@@ -1,57 +0,0 @@
1/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* Always build .init and .fini sections in ARM mode. */
37#define NO_THUMB
38#include <sysdep.h>
39
40/* crtn.S puts function epilogues in the .init and .fini sections
41 corresponding to the prologues in crti.S. */
42
43 .section .init,"ax",%progbits
44#ifdef __ARM_ARCH_4T__
45 pop {r3, lr}
46 bx lr
47#else
48 pop {r3, pc}
49#endif
50
51 .section .fini,"ax",%progbits
52#ifdef __ARM_ARCH_4T__
53 pop {r3, lr}
54 bx lr
55#else
56 pop {r3, pc}
57#endif
lib/libc/glibc/sysdeps/hppa/crti.S deleted-162
...@@ -1,162 +0,0 @@
1/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58
59/* If we have working .init_array support, we want to keep the .init
60 section empty (apart from the mandatory prologue/epilogue. This
61 ensures that the default unwind conventions (return-pointer in b0,
62 frame state in ar.pfs, etc.) will do the Right Thing. To ensure
63 an empty .init section, we register gmon_initializer() via the
64 .init_array.
65
66 --davidm 02/10/29 */
67
68#if PREINIT_FUNCTION_WEAK
69/* This blob of assembly code is one simple C function:
70
71static void
72__attribute__ ((used))
73gmon_initializer (void)
74{
75 extern void weak_function __gmon_start__ (void);
76
77 if (__gmon_start__)
78 (*__gmon_start__)();
79}
80
81In a final executable, PLABEL32 relocations for function pointers are
82resolved at link time. Typically, binutils/ld resolves __gmon_start__
83using an external shared library. __gmon_start__ is always called if
84it is found at link time. If __gmon_start__ is not found at runtime
85due to a library update, then the function pointer will point at a null
86function descriptor and calling it will cause a segmentation fault.
87So, we call __canonicalize_funcptr_for_compare to obtain the canonicalized
88address of __gmon_start__ and skip calling __gmon_start__ if it is zero.
89
90 */
91 .type __canonicalize_funcptr_for_compare,@function
92 .type $$dyncall,@function
93
94 .section .data.rel.ro,"aw",@progbits
95 .align 4
96.LC0:
97 .type __gmon_start__,@function
98 .word P%__gmon_start__
99
100 .text
101 .align 4
102 .type gmon_initializer,@function
103gmon_initializer:
104 .PROC
105 .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=4
106 .ENTRY
107 stw %r2,-20(%r30)
108 stwm %r4,64(%r30)
109 stw %r3,-60(%r30)
110 addil LT'.LC0,%r19
111 ldw RT'.LC0(%r1),%r28
112 ldw 0(%r28),%r3
113 comib,= 0,%r3,1f
114 copy %r19,%r4
115 stw %r19,-32(%r30)
116 bl __canonicalize_funcptr_for_compare,%r2
117 copy %r3,%r26
118 comib,= 0,%r28,1f
119 copy %r4,%r19
120 copy %r3,%r22
121 .CALL ARGW0=GR
122 bl $$dyncall,%r31
123 copy %r31,%r2
1241:
125 ldw -84(%r30),%r2
126 ldw -60(%r30),%r3
127 bv %r0(%r2)
128 ldwm -64(%r30),%r4
129 .EXIT
130 .PROCEND
131 .size gmon_initializer, .-gmon_initializer
132
133# undef PREINIT_FUNCTION
134# define PREINIT_FUNCTION gmon_initializer
135#endif
136
137 .section .init_array, "aw"
138 .word P% PREINIT_FUNCTION
139
140
141/* _init prologue. */
142 .section .init, "ax", %progbits
143 .align 4
144 .globl _init
145 .hidden _init
146 .type _init,@function
147_init:
148 stw %rp,-20(%sp)
149 stwm %r4,64(%sp)
150 stw %r19,-32(%sp)
151
152/* _fini prologue. */
153 .section .fini,"ax",%progbits
154 .align 4
155 .globl _fini
156 .hidden _fini
157 .type _fini,@function
158_fini:
159 stw %rp,-20(%sp)
160 stwm %r4,64(%sp)
161 stw %r19,-32(%sp)
162 copy %r19,%r4
lib/libc/glibc/sysdeps/hppa/crtn.S deleted-66
...@@ -1,66 +0,0 @@
1/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36#include <sysdep.h>
37
38/* crtn.S puts function epilogues in the .init and .fini sections
39 corresponding to the prologues in crti.S. */
40
41 .section .init, "ax", @progbits
42 ldw -84(%sp),%rp
43 copy %r4,%r19
44 bv %r0(%rp)
45_end_init:
46 ldwm -64(%sp),%r4
47
48/* Our very own unwind info, because the assembler can't handle
49 functions split into two or more pieces. */
50 .section .PARISC.unwind
51 .extern _init
52 .word _init, _end_init
53 .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
54
55/* Here is the tail end of _fini. */
56 .section .fini, "ax", @progbits
57 ldw -84(%sp),%rp
58 copy %r4,%r19
59 bv %r0(%rp)
60_end_fini:
61 ldwm -64(%sp),%r4
62
63 .section .PARISC.unwind
64 .extern _fini
65 .word _fini, _end_fini
66 .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
lib/libc/glibc/sysdeps/i386/crti.S deleted-86
...@@ -1,86 +0,0 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 pushl %ebx
65 /* Maintain 16-byte stack alignment for called functions. */
66 subl $8, %esp
67 LOAD_PIC_REG (bx)
68#if PREINIT_FUNCTION_WEAK
69 movl PREINIT_FUNCTION@GOT(%ebx), %eax
70 testl %eax, %eax
71 je .Lno_weak_fn
72 call *%eax
73.Lno_weak_fn:
74#else
75 call PREINIT_FUNCTION
76#endif
77
78 .section .fini,"ax",@progbits
79 .p2align 2
80 .globl _fini
81 .hidden _fini
82 .type _fini, @function
83_fini:
84 pushl %ebx
85 subl $8, %esp
86 LOAD_PIC_REG (bx)
lib/libc/glibc/sysdeps/i386/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addl $8, %esp
41 popl %ebx
42 ret
43
44 .section .fini,"ax",@progbits
45 addl $8, %esp
46 popl %ebx
47 ret
lib/libc/glibc/sysdeps/m68k/crti.S deleted-84
...@@ -1,84 +0,0 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 link.w %fp, #0
65 move.l %a5, -(%sp)
66 LOAD_GOT (%a5)
67#if PREINIT_FUNCTION_WEAK
68 tst.l PREINIT_FUNCTION@GOT(%a5)
69 jeq 1f
70 jbsr PREINIT_FUNCTION@PLTPC
711:
72#else
73 jbsr PREINIT_FUNCTION
74#endif
75
76 .section .fini,"ax",@progbits
77 .align 2
78 .globl _fini
79 .hidden _fini
80 .type _fini, @function
81_fini:
82 link.w %fp, #0
83 move.l %a5, -(%sp)
84 LOAD_GOT (%a5)
lib/libc/glibc/sysdeps/m68k/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 move.l -4(%fp), %a5
41 unlk %fp
42 rts
43
44 .section .fini,"ax",@progbits
45 move.l -4(%fp), %a5
46 unlk %fp
47 rts
lib/libc/glibc/sysdeps/microblaze/crti.S deleted-90
...@@ -1,90 +0,0 @@
1/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 addik r1,r1,-32
65 swi r20,r1,28
66 mfs r20,rpc
67 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
68 lwi r3,r20,PREINIT_FUNCTION@GOT
69#if PREINIT_FUNCTION_WEAK
70 beqid r3,$Lno_weak_fn:
71 swi r15,r1,0
72 brlid r15,PREINIT_FUNCTION@PLT
73$Lno_weak_fn:
74#else
75 swi r15,r1,0
76 brald r15,r3
77#endif
78 nop # Unfilled delay slot
79
80 .section .fini,"ax",@progbits
81 .align 2
82 .globl _fini
83 .hidden _fini
84 .type _fini, @function
85_fini:
86 addik r1,r1,-32
87 swi r20,r1,28
88 swi r15,r1,0
89 mfs r20,rpc
90 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lib/libc/glibc/sysdeps/microblaze/crtn.S deleted-51
...@@ -1,51 +0,0 @@
1/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 lwi r15,r1,0
43 lwi r20,r1,28
44 rtsd r15,8
45 addik r1,r1,32
46
47 .section .fini,"ax",@progbits
48 lwi r15,r1,0
49 lwi r20,r1,28
50 rtsd r15,8
51 addik r1,r1,32
lib/libc/glibc/sysdeps/mips/mips32/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 .set noreorder
72 .cpload $25
73 .set reorder
74 addiu $sp,$sp,-32
75 .cprestore 16
76 sw $31,28($sp)
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 .set noreorder
98 .cpload $25
99 .set reorder
100 addiu $sp,$sp,-32
101 .cprestore 16
102 sw $31,28($sp)
lib/libc/glibc/sysdeps/mips/mips32/crtn.S deleted-59
...@@ -1,59 +0,0 @@
1/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 lw $31,28($sp)
43 .set noreorder
44 .set nomacro
45 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
46 jr $31
47 addiu $sp,$sp,32
48 .set macro
49 .set reorder
50
51 .section .fini,"ax",@progbits
52 lw $31,28($sp)
53 .set noreorder
54 .set nomacro
55 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
56 jr $31
57 addiu $sp,$sp,32
58 .set macro
59 .set reorder
lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 addiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 addu $28,$28,$25
75 sd $31,8($sp)
76 addiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 lw $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 lw $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 lw $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 addiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 addu $28,$28,$25
101 sd $31,8($sp)
102 addiu $28,$28,%lo(%neg(%gp_rel(_fini)))
lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S deleted-61
...@@ -1,61 +0,0 @@
1/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
47 jr $31
48 addiu $sp,$sp,16
49 .set macro
50 .set reorder
51
52 .section .fini,"ax",@progbits
53 ld $31,8($sp)
54 ld $28,0($sp)
55 .set noreorder
56 .set nomacro
57 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
58 jr $31
59 addiu $sp,$sp,16
60 .set macro
61 .set reorder
lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S deleted-102
...@@ -1,102 +0,0 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42
43#ifdef __mips_micromips
44# define JALR_RELOC R_MICROMIPS_JALR
45#else
46# define JALR_RELOC R_MIPS_JALR
47#endif
48
49#ifndef PREINIT_FUNCTION
50# define PREINIT_FUNCTION __gmon_start__
51#endif
52
53#ifndef PREINIT_FUNCTION_WEAK
54# define PREINIT_FUNCTION_WEAK 1
55#endif
56
57#if PREINIT_FUNCTION_WEAK
58 weak_extern (PREINIT_FUNCTION)
59#else
60 .hidden PREINIT_FUNCTION
61#endif
62
63 .set nomips16
64
65 .section .init,"ax",@progbits
66 .p2align 2
67 .globl _init
68 .hidden _init
69 .type _init, @function
70_init:
71 daddiu $sp,$sp,-16
72 sd $28,0($sp)
73 lui $28,%hi(%neg(%gp_rel(_init)))
74 daddu $28,$28,$25
75 sd $31,8($sp)
76 daddiu $28,$28,%lo(%neg(%gp_rel(_init)))
77#if PREINIT_FUNCTION_WEAK
78 ld $2,%got_disp(PREINIT_FUNCTION)($28)
79 beq $2,$0,.Lno_weak_fn
80 ld $25,%call16(PREINIT_FUNCTION)($28)
81 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
821: jalr $25
83.Lno_weak_fn:
84 .insn
85#else
86 ld $25,%got_disp(PREINIT_FUNCTION)($28)
87 .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
881: jalr $25
89#endif
90
91 .section .fini,"ax",@progbits
92 .p2align 2
93 .globl _fini
94 .hidden _fini
95 .type _fini, @function
96_fini:
97 daddiu $sp,$sp,-16
98 sd $28,0($sp)
99 lui $28,%hi(%neg(%gp_rel(_fini)))
100 daddu $28,$28,$25
101 sd $31,8($sp)
102 daddiu $28,$28,%lo(%neg(%gp_rel(_fini)))
lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S deleted-61
...@@ -1,61 +0,0 @@
1/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library. If not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .set nomips16
40
41 .section .init,"ax",@progbits
42 ld $31,8($sp)
43 ld $28,0($sp)
44 .set noreorder
45 .set nomacro
46 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
47 jr $31
48 daddiu $sp,$sp,16
49 .set macro
50 .set reorder
51
52 .section .fini,"ax",@progbits
53 ld $31,8($sp)
54 ld $28,0($sp)
55 .set noreorder
56 .set nomacro
57 /* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
58 jr $31
59 daddiu $sp,$sp,16
60 .set macro
61 .set reorder
lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S deleted-91
...@@ -1,91 +0,0 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 stwu r1, -16(r1)
65 mflr r0
66 stw r0, 20(r1)
67 stw r30, 8(r1)
68 SETUP_GOT_ACCESS (r30, .Lgot_label_i)
69 addis r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@ha
70 addi r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@l
71#if PREINIT_FUNCTION_WEAK
72 lwz r0, PREINIT_FUNCTION@got(r30)
73 cmpwi cr7, r0, 0
74 beq+ cr7, 1f
75 bl PREINIT_FUNCTION@plt
761:
77#else
78 bl PREINIT_FUNCTION@local
79#endif
80
81 .section .fini,"ax",@progbits
82 .align 2
83 .globl _fini
84 .hidden _fini
85 .type _fini, @function
86_fini:
87 stwu r1, -16(r1)
88 mflr r0
89 stw r0, 20(r1)
90 stw r30, 8(r1)
91 SETUP_GOT_ACCESS (r30, .Lgot_label_f)
lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S deleted-53
...@@ -1,53 +0,0 @@
1/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 lwz r0, 20(r1)
43 mtlr r0
44 lwz r30, 8(r1)
45 addi r1, r1, 16
46 blr
47
48 .section .fini,"ax",@progbits
49 lwz r0, 20(r1)
50 mtlr r0
51 lwz r30, 8(r1)
52 addi r1, r1, 16
53 blr
lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S deleted-90
...@@ -1,90 +0,0 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#if PREINIT_FUNCTION_WEAK
59 .section ".toc", "aw"
60.LC0:
61 .tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
62#endif
63 .section ".init", "ax", @progbits
64 ENTRY_2(_init)
65 .hidden _init
66 .align ALIGNARG (2)
67BODY_LABEL (_init):
68 LOCALENTRY(_init)
69 mflr 0
70 std 0, FRAME_LR_SAVE(r1)
71 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
72#if PREINIT_FUNCTION_WEAK
73 addis r9, r2, .LC0@toc@ha
74 ld r0, .LC0@toc@l(r9)
75 cmpdi cr7, r0, 0
76 beq+ cr7, 1f
77#endif
78 bl JUMPTARGET (PREINIT_FUNCTION)
79 nop
801:
81
82 .section ".fini", "ax", @progbits
83 ENTRY_2(_fini)
84 .hidden _fini
85 .align ALIGNARG (2)
86BODY_LABEL (_fini):
87 LOCALENTRY(_fini)
88 mflr 0
89 std 0, FRAME_LR_SAVE(r1)
90 stdu r1, -FRAME_MIN_SIZE_PARM(r1)
lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S deleted-51
...@@ -1,51 +0,0 @@
1/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39#include <sysdep.h>
40
41 .section .init,"ax",@progbits
42 addi r1, r1, FRAME_MIN_SIZE_PARM
43 ld r0, FRAME_LR_SAVE(r1)
44 mtlr r0
45 blr
46
47 .section .fini,"ax",@progbits
48 addi r1, r1, FRAME_MIN_SIZE_PARM
49 ld r0, FRAME_LR_SAVE(r1)
50 mtlr r0
51 blr
lib/libc/glibc/sysdeps/s390/s390-32/crti.S deleted-104
...@@ -1,104 +0,0 @@
1/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .globl _init
60 .hidden _init
61 .type _init,@function
62 .align 4
63_init:
64 stm %r6,%r15,24(%r15)
65 bras %r13,1f
660:
67#if PREINIT_FUNCTION_WEAK
68 .long PREINIT_FUNCTION@GOT
69#else
70 .long PREINIT_FUNCTION-0b
71#endif
72 .long _GLOBAL_OFFSET_TABLE_-0b
731: lr %r1,%r15
74 ahi %r15,-96
75 st %r1,0(%r15)
76 l %r12,4(%r13)
77 ar %r12,%r13
78 l %r1,0(%r13)
79#if PREINIT_FUNCTION_WEAK
80 l %r1,0(%r1,%r12)
81 ltr %r1,%r1
82 je 2f
83#else
84 la %r1,0(%r1,%r13)
85#endif
86 basr %r14,%r1
87 .align 4,0x07
882:
89
90 .section .fini,"ax",@progbits
91 .globl _fini
92 .hidden _fini
93 .type _fini,@function
94 .align 4
95_fini:
96 stm %r6,%r15,24(%r15)
97 bras %r13,1f
980: .long _GLOBAL_OFFSET_TABLE_-0b
991: lr %r1,%r15
100 ahi %r15,-96
101 st %r1,0(%r15)
102 l %r12,0(%r13)
103 ar %r12,%r13
104 .align 4,0x07
lib/libc/glibc/sysdeps/s390/s390-32/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 l %r4,152(%r15)
41 lm %r6,%r15,120(%r15)
42 br %r4
43
44 .section .fini,"ax",@progbits
45 l %r4,152(%r15)
46 lm %r6,%r15,120(%r15)
47 br %r4
lib/libc/glibc/sysdeps/s390/s390-64/crti.S deleted-93
...@@ -1,93 +0,0 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 4
60 .globl _init
61 .hidden _init
62 .type _init,@function
63_init:
64 stmg %r6,%r15,48(%r15)
65 lgr %r1,%r15
66 aghi %r15,-160
67 stg %r1,0(%r15)
68 larl %r12,_GLOBAL_OFFSET_TABLE_
69#if PREINIT_FUNCTION_WEAK
70 /* zig patch: GOTENT -> GOT. revert with llvm 20. */
71 larl %r1,PREINIT_FUNCTION@GOT
72 lg %r1,0(%r1)
73 ltgr %r1,%r1
74 je 1f
75 basr %r14,%r1
76#else
77 brasl %r14,PREINIT_FUNCTION
78#endif
79 .align 4,0x07
801:
81
82 .section .fini,"ax",@progbits
83 .align 4
84 .globl _fini
85 .hidden _fini
86 .type _fini,@function
87_fini:
88 stmg %r6,%r15,48(%r15)
89 lg %r1,120(%r15)
90 aghi %r15,-160
91 stg %r1,0(%r15)
92 larl %r12,_GLOBAL_OFFSET_TABLE_
93 .align 4,0x07
lib/libc/glibc/sysdeps/s390/s390-64/crtn.S deleted-47
...@@ -1,47 +0,0 @@
1/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init
40 lg %r4,272(%r15)
41 lmg %r6,%r15,208(%r15)
42 br %r4
43
44 .section .fini
45 lg %r4,272(%r15)
46 lmg %r6,%r15,208(%r15)
47 br %r4
lib/libc/glibc/sysdeps/sh/crti.S deleted-122
...@@ -1,122 +0,0 @@
1/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .align 5
60 .global _init
61 .hidden _init
62 .type _init, @function
63_init:
64 mov.l r12,@-r15
65 mova .L12,r0
66 mov.l .L12,r12
67 mov.l r14,@-r15
68 add r0,r12
69 sts.l pr,@-r15
70#if PREINIT_FUNCTION_WEAK
71 mov.l .L13,r0
72 mov.l @(r0,r12),r1
73 tst r1,r1
74 bt/s .L8
75 mov r15,r14
76 mov.l .L14,r1
77 bsrf r1
78.LPCS0:
79 nop
80.L8:
81#else
82 mova .L13,r0
83 mov.l .L13,r1
84 add r0,r1
85 jsr @r1
86 mov r15,r14
87#endif
88 bra 1f
89 nop
90 .align 2
91.L12:
92 .long _GLOBAL_OFFSET_TABLE_
93#if PREINIT_FUNCTION_WEAK
94.L13:
95 .long PREINIT_FUNCTION@GOT
96.L14:
97 .long PREINIT_FUNCTION@PLT-(.LPCS0+2-(.))
98#else
99.L13:
100 .long PREINIT_FUNCTION@PLT
101#endif
1021:
103
104 .section .fini,"ax",@progbits
105 .align 5
106 .global _fini
107 .hidden _fini
108 .type _fini, @function
109_fini:
110 mov.l r12,@-r15
111 mova .L19,r0
112 mov.l r14,@-r15
113 sts.l pr,@-r15
114 mov.l .L19,r12
115 mov r15,r14
116 add r0,r12
117 bra 0f
118 nop
119 .align 2
120.L19:
121 .long _GLOBAL_OFFSET_TABLE_
1220:
lib/libc/glibc/sysdeps/sh/crtn.S deleted-53
...@@ -1,53 +0,0 @@
1/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 mov r14,r15
41 lds.l @r15+,pr
42 mov.l @r15+,r14
43 mov.l @r15+,r12
44 rts
45 nop
46
47 .section .fini,"ax",@progbits
48 mov r14,r15
49 lds.l @r15+,pr
50 mov.l @r15+,r14
51 mov.l @r15+,r12
52 rts
53 nop
lib/libc/glibc/sysdeps/sparc/crti.S deleted-95
...@@ -1,95 +0,0 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58#ifdef __arch64__
59#define STACKFRAME_SIZE 176
60#define GOT_LOAD ldx
61#else
62#define STACKFRAME_SIZE 96
63#define GOT_LOAD ld
64#endif
65
66 .section .init,"ax",@progbits
67 .p2align 2
68 .globl _init
69 .hidden _init
70 .type _init, @function
71_init:
72 save %sp, -STACKFRAME_SIZE, %sp
73#if PREINIT_FUNCTION_WEAK
74 SETUP_PIC_REG(l7)
75 sethi %gdop_hix22(PREINIT_FUNCTION), %g1
76 xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1
77 GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION)
78 cmp %g1, 0
79 be 1f
80 nop
81 call PREINIT_FUNCTION
82 nop
831:
84#else
85 call PREINIT_FUNCTION
86 nop
87#endif
88
89 .section .fini,"ax",@progbits
90 .p2align 2
91 .globl _fini
92 .hidden _fini
93 .type _fini, @function
94_fini:
95 save %sp, -STACKFRAME_SIZE, %sp
lib/libc/glibc/sysdeps/sparc/crtn.S deleted-45
...@@ -1,45 +0,0 @@
1/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 jmp %i7 + 8
41 restore
42
43 .section .fini,"ax",@progbits
44 jmp %i7 + 8
45 restore
lib/libc/glibc/sysdeps/x86_64/crti.S deleted-84
...@@ -1,84 +0,0 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crti.S puts a function prologue at the beginning of the .init and
37 .fini sections and defines global symbols for those addresses, so
38 they can be called as functions. The symbols _init and _fini are
39 magic and cause the linker to emit DT_INIT and DT_FINI. */
40
41#include <libc-symbols.h>
42#include <sysdep.h>
43
44#ifndef PREINIT_FUNCTION
45# define PREINIT_FUNCTION __gmon_start__
46#endif
47
48#ifndef PREINIT_FUNCTION_WEAK
49# define PREINIT_FUNCTION_WEAK 1
50#endif
51
52#if PREINIT_FUNCTION_WEAK
53 weak_extern (PREINIT_FUNCTION)
54#else
55 .hidden PREINIT_FUNCTION
56#endif
57
58 .section .init,"ax",@progbits
59 .p2align 2
60 .globl _init
61 .hidden _init
62 .type _init, @function
63_init:
64 _CET_ENDBR
65 /* Maintain 16-byte stack alignment for called functions. */
66 subq $8, %rsp
67#if PREINIT_FUNCTION_WEAK
68 movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax
69 testq %rax, %rax
70 je .Lno_weak_fn
71 call *%rax
72.Lno_weak_fn:
73#else
74 call PREINIT_FUNCTION
75#endif
76
77 .section .fini,"ax",@progbits
78 .p2align 2
79 .globl _fini
80 .hidden _fini
81 .type _fini, @function
82_fini:
83 _CET_ENDBR
84 subq $8, %rsp
lib/libc/glibc/sysdeps/x86_64/crtn.S deleted-45
...@@ -1,45 +0,0 @@
1/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2024 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 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.)
18
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.
26
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.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36/* crtn.S puts function epilogues in the .init and .fini sections
37 corresponding to the prologues in crti.S. */
38
39 .section .init,"ax",@progbits
40 addq $8, %rsp
41 ret
42
43 .section .fini,"ax",@progbits
44 addq $8, %rsp
45 ret
lib/libc/musl/crt/aarch64/crti.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.global _init
3.type _init,%function
4_init:
5 stp x29,x30,[sp,-16]!
6 mov x29,sp
7
8.section .fini
9.global _fini
10.type _fini,%function
11_fini:
12 stp x29,x30,[sp,-16]!
13 mov x29,sp
lib/libc/musl/crt/aarch64/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 ldp x29,x30,[sp],#16
3 ret
4
5.section .fini
6 ldp x29,x30,[sp],#16
7 ret
lib/libc/musl/crt/arm/crti.s deleted-15
...@@ -1,15 +0,0 @@
1.syntax unified
2
3.section .init
4.global _init
5.type _init,%function
6.align 2
7_init:
8 push {r0,lr}
9
10.section .fini
11.global _fini
12.type _fini,%function
13.align 2
14_fini:
15 push {r0,lr}
lib/libc/musl/crt/arm/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.syntax unified
2
3.section .init
4 pop {r0,lr}
5 bx lr
6
7.section .fini
8 pop {r0,lr}
9 bx lr
lib/libc/musl/crt/crti.c deleted
lib/libc/musl/crt/crtn.c deleted
lib/libc/musl/crt/i386/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 sub $12,%esp
5
6.section .fini
7.global _fini
8_fini:
9 sub $12,%esp
lib/libc/musl/crt/i386/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 add $12,%esp
3 ret
4
5.section .fini
6 add $12,%esp
7 ret
lib/libc/musl/crt/microblaze/crti.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.global _init
3.align 2
4_init:
5 addi r1, r1, -32
6 swi r15, r1, 0
7
8.section .fini
9.global _fini
10.align 2
11_fini:
12 addi r1, r1, -32
13 swi r15, r1, 0
lib/libc/musl/crt/microblaze/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2 lwi r15, r1, 0
3 rtsd r15, 8
4 addi r1, r1, 32
5
6.section .fini
7 lwi r15, r1, 0
8 rtsd r15, 8
9 addi r1, r1, 32
lib/libc/musl/crt/mips/crti.s deleted-19
...@@ -1,19 +0,0 @@
1.set noreorder
2
3.section .init
4.global _init
5.type _init,@function
6.align 2
7_init:
8 subu $sp,$sp,32
9 sw $gp,24($sp)
10 sw $ra,28($sp)
11
12.section .fini
13.global _fini
14.type _fini,@function
15.align 2
16_fini:
17 subu $sp,$sp,32
18 sw $gp,24($sp)
19 sw $ra,28($sp)
lib/libc/musl/crt/mips/crtn.s deleted-15
...@@ -1,15 +0,0 @@
1.set noreorder
2
3.section .init
4 lw $gp,24($sp)
5 lw $ra,28($sp)
6 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
7 jr $ra
8 addu $sp,$sp,32
9
10.section .fini
11 lw $gp,24($sp)
12 lw $ra,28($sp)
13 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
14 jr $ra
15 addu $sp,$sp,32
lib/libc/musl/crt/mips64/crti.s deleted-17
...@@ -1,17 +0,0 @@
1.set noreorder
2
3.section .init
4.global _init
5.align 3
6_init:
7 dsubu $sp, $sp, 32
8 sd $gp, 16($sp)
9 sd $ra, 24($sp)
10
11.section .fini
12.global _fini
13.align 3
14_fini:
15 dsubu $sp, $sp, 32
16 sd $gp, 16($sp)
17 sd $ra, 24($sp)
lib/libc/musl/crt/mips64/crtn.s deleted-15
...@@ -1,15 +0,0 @@
1.set noreorder
2
3.section .init
4 ld $gp,16($sp)
5 ld $ra,24($sp)
6 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
7 jr $ra
8 daddu $sp,$sp,32
9
10.section .fini
11 ld $gp,16($sp)
12 ld $ra,24($sp)
13 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
14 jr $ra
15 daddu $sp,$sp,32
lib/libc/musl/crt/mipsn32/crti.s deleted-18
...@@ -1,18 +0,0 @@
1.set noreorder
2.section .init
3.global _init
4.type _init,@function
5.align 2
6_init:
7 subu $sp, $sp, 32
8 sd $gp, 16($sp)
9 sd $ra, 24($sp)
10
11.section .fini
12.global _fini
13.type _fini,@function
14.align 2
15_fini:
16 subu $sp, $sp, 32
17 sd $gp, 16($sp)
18 sd $ra, 24($sp)
lib/libc/musl/crt/mipsn32/crtn.s deleted-14
...@@ -1,14 +0,0 @@
1.set noreorder
2.section .init
3 ld $gp, 16($sp)
4 ld $ra, 24($sp)
5 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
6 jr $ra
7 addu $sp, $sp, 32
8
9.section .fini
10 ld $gp, 16($sp)
11 ld $ra, 24($sp)
12 # zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
13 jr $ra
14 addu $sp, $sp, 32
lib/libc/musl/crt/or1k/crti.s deleted-11
...@@ -1,11 +0,0 @@
1.section .init
2.global _init
3_init:
4 l.addi r1,r1,-4
5 l.sw 0(r1),r9
6
7.section .fini
8.global _fini
9_fini:
10 l.addi r1,r1,-4
11 l.sw 0(r1),r9
lib/libc/musl/crt/or1k/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2 l.lwz r9,0(r1)
3 l.jr r9
4 l.addi r1,r1,4
5
6.section .fini
7 l.lwz r9,0(r1)
8 l.jr r9
9 l.addi r1,r1,4
lib/libc/musl/crt/powerpc/crti.s deleted-15
...@@ -1,15 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 stwu 1,-32(1)
6 mflr 0
7 stw 0,36(1)
8
9.section .fini
10.align 2
11.global _fini
12_fini:
13 stwu 1,-32(1)
14 mflr 0
15 stw 0,36(1)
lib/libc/musl/crt/powerpc/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.align 2
3 lwz 0,36(1)
4 addi 1,1,32
5 mtlr 0
6 blr
7
8.section .fini
9.align 2
10 lwz 0,36(1)
11 addi 1,1,32
12 mtlr 0
13 blr
lib/libc/musl/crt/powerpc64/crti.s deleted-21
...@@ -1,21 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 addis 2, 12, .TOC.-_init@ha
6 addi 2, 2, .TOC.-_init@l
7 .localentry _init,.-_init
8 mflr 0
9 std 0, 16(1)
10 stdu 1,-32(1)
11
12.section .fini
13.align 2
14.global _fini
15_fini:
16 addis 2, 12, .TOC.-_fini@ha
17 addi 2, 2, .TOC.-_fini@l
18 .localentry _fini,.-_fini
19 mflr 0
20 std 0, 16(1)
21 stdu 1,-32(1)
lib/libc/musl/crt/powerpc64/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2.align 2
3 addi 1, 1, 32
4 ld 0, 16(1)
5 mtlr 0
6 blr
7
8.section .fini
9.align 2
10 addi 1, 1, 32
11 ld 0, 16(1)
12 mtlr 0
13 blr
lib/libc/musl/crt/s390x/crti.s deleted-17
...@@ -1,17 +0,0 @@
1.section .init
2.align 2
3.global _init
4_init:
5 stmg %r14, %r15, 112(%r15)
6 lgr %r0, %r15
7 aghi %r15, -160
8 stg %r0, 0(%r15)
9
10.section .fini
11.align 2
12.global _fini
13_fini:
14 stmg %r14, %r15, 112(%r15)
15 lgr %r0, %r15
16 aghi %r15, -160
17 stg %r0, 0(%r15)
lib/libc/musl/crt/s390x/crtn.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.align 2
3 lmg %r14, %r15, 272(%r15)
4 br %r14
5
6.section .fini
7.align 2
8 lmg %r14, %r15, 272(%r15)
9 br %r14
lib/libc/musl/crt/sh/crti.s deleted-21
...@@ -1,21 +0,0 @@
1.section .init
2.global _init
3.type _init, @function
4_init:
5 add #-4, r15
6 mov.l r12, @-r15
7 mov.l r14, @-r15
8 sts.l pr, @-r15
9 mov r15, r14
10 nop
11
12.section .fini
13.global _fini
14.type _fini, @function
15_fini:
16 add #-4, r15
17 mov.l r12, @-r15
18 mov.l r14, @-r15
19 sts.l pr, @-r15
20 mov r15, r14
21 nop
lib/libc/musl/crt/sh/crtn.s deleted-13
...@@ -1,13 +0,0 @@
1.section .init
2 lds.l @r15+, pr
3 mov.l @r15+, r14
4 mov.l @r15+, r12
5 rts
6 add #4, r15
7
8.section .fini
9 lds.l @r15+, pr
10 mov.l @r15+, r14
11 mov.l @r15+, r12
12 rts
13 add #4, r15
lib/libc/musl/crt/x32/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 push %rax
5
6.section .fini
7.global _fini
8_fini:
9 push %rax
lib/libc/musl/crt/x32/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 pop %rax
3 ret
4
5.section .fini
6 pop %rax
7 ret
lib/libc/musl/crt/x86_64/crti.s deleted-9
...@@ -1,9 +0,0 @@
1.section .init
2.global _init
3_init:
4 push %rax
5
6.section .fini
7.global _fini
8_fini:
9 push %rax
lib/libc/musl/crt/x86_64/crtn.s deleted-7
...@@ -1,7 +0,0 @@
1.section .init
2 pop %rax
3 ret
4
5.section .fini
6 pop %rax
7 ret
lib/std/zig/LibCInstallation.zig+2-68
...@@ -694,10 +694,8 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void {...@@ -694,10 +694,8 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void {
694/// `CsuPaths`.694/// `CsuPaths`.
695pub const CrtBasenames = struct {695pub const CrtBasenames = struct {
696 crt0: ?[]const u8 = null,696 crt0: ?[]const u8 = null,
697 crti: ?[]const u8 = null,
698 crtbegin: ?[]const u8 = null,697 crtbegin: ?[]const u8 = null,
699 crtend: ?[]const u8 = null,698 crtend: ?[]const u8 = null,
700 crtn: ?[]const u8 = null,
701699
702 pub const GetArgs = struct {700 pub const GetArgs = struct {
703 target: std.Target,701 target: std.Target,
...@@ -751,137 +749,96 @@ pub const CrtBasenames = struct {...@@ -751,137 +749,96 @@ pub const CrtBasenames = struct {
751749
752 return switch (target.os.tag) {750 return switch (target.os.tag) {
753 .linux => switch (mode) {751 .linux => switch (mode) {
754 .dynamic_lib => .{752 .dynamic_lib => .{},
755 .crti = "crti.o",
756 .crtn = "crtn.o",
757 },
758 .dynamic_exe => .{753 .dynamic_exe => .{
759 .crt0 = "crt1.o",754 .crt0 = "crt1.o",
760 .crti = "crti.o",
761 .crtn = "crtn.o",
762 },755 },
763 .dynamic_pie => .{756 .dynamic_pie => .{
764 .crt0 = "Scrt1.o",757 .crt0 = "Scrt1.o",
765 .crti = "crti.o",
766 .crtn = "crtn.o",
767 },758 },
768 .static_exe => .{759 .static_exe => .{
769 .crt0 = "crt1.o",760 .crt0 = "crt1.o",
770 .crti = "crti.o",
771 .crtn = "crtn.o",
772 },761 },
773 .static_pie => .{762 .static_pie => .{
774 .crt0 = "rcrt1.o",763 .crt0 = "rcrt1.o",
775 .crti = "crti.o",
776 .crtn = "crtn.o",
777 },764 },
778 },765 },
779 .dragonfly => switch (mode) {766 .dragonfly => switch (mode) {
780 .dynamic_lib => .{767 .dynamic_lib => .{
781 .crti = "crti.o",
782 .crtbegin = "crtbeginS.o",768 .crtbegin = "crtbeginS.o",
783 .crtend = "crtendS.o",769 .crtend = "crtendS.o",
784 .crtn = "crtn.o",
785 },770 },
786 .dynamic_exe => .{771 .dynamic_exe => .{
787 .crt0 = "crt1.o",772 .crt0 = "crt1.o",
788 .crti = "crti.o",
789 .crtbegin = "crtbegin.o",773 .crtbegin = "crtbegin.o",
790 .crtend = "crtend.o",774 .crtend = "crtend.o",
791 .crtn = "crtn.o",
792 },775 },
793 .dynamic_pie => .{776 .dynamic_pie => .{
794 .crt0 = "Scrt1.o",777 .crt0 = "Scrt1.o",
795 .crti = "crti.o",
796 .crtbegin = "crtbeginS.o",778 .crtbegin = "crtbeginS.o",
797 .crtend = "crtendS.o",779 .crtend = "crtendS.o",
798 .crtn = "crtn.o",
799 },780 },
800 .static_exe => .{781 .static_exe => .{
801 .crt0 = "crt1.o",782 .crt0 = "crt1.o",
802 .crti = "crti.o",
803 .crtbegin = "crtbegin.o",783 .crtbegin = "crtbegin.o",
804 .crtend = "crtend.o",784 .crtend = "crtend.o",
805 .crtn = "crtn.o",
806 },785 },
807 .static_pie => .{786 .static_pie => .{
808 .crt0 = "Scrt1.o",787 .crt0 = "Scrt1.o",
809 .crti = "crti.o",
810 .crtbegin = "crtbeginS.o",788 .crtbegin = "crtbeginS.o",
811 .crtend = "crtendS.o",789 .crtend = "crtendS.o",
812 .crtn = "crtn.o",
813 },790 },
814 },791 },
815 .freebsd => switch (mode) {792 .freebsd => switch (mode) {
816 .dynamic_lib => .{793 .dynamic_lib => .{
817 .crti = "crti.o",
818 .crtbegin = "crtbeginS.o",794 .crtbegin = "crtbeginS.o",
819 .crtend = "crtendS.o",795 .crtend = "crtendS.o",
820 .crtn = "crtn.o",
821 },796 },
822 .dynamic_exe => .{797 .dynamic_exe => .{
823 .crt0 = "crt1.o",798 .crt0 = "crt1.o",
824 .crti = "crti.o",
825 .crtbegin = "crtbegin.o",799 .crtbegin = "crtbegin.o",
826 .crtend = "crtend.o",800 .crtend = "crtend.o",
827 .crtn = "crtn.o",
828 },801 },
829 .dynamic_pie => .{802 .dynamic_pie => .{
830 .crt0 = "Scrt1.o",803 .crt0 = "Scrt1.o",
831 .crti = "crti.o",
832 .crtbegin = "crtbeginS.o",804 .crtbegin = "crtbeginS.o",
833 .crtend = "crtendS.o",805 .crtend = "crtendS.o",
834 .crtn = "crtn.o",
835 },806 },
836 .static_exe => .{807 .static_exe => .{
837 .crt0 = "crt1.o",808 .crt0 = "crt1.o",
838 .crti = "crti.o",
839 .crtbegin = "crtbeginT.o",809 .crtbegin = "crtbeginT.o",
840 .crtend = "crtend.o",810 .crtend = "crtend.o",
841 .crtn = "crtn.o",
842 },811 },
843 .static_pie => .{812 .static_pie => .{
844 .crt0 = "Scrt1.o",813 .crt0 = "Scrt1.o",
845 .crti = "crti.o",
846 .crtbegin = "crtbeginS.o",814 .crtbegin = "crtbeginS.o",
847 .crtend = "crtendS.o",815 .crtend = "crtendS.o",
848 .crtn = "crtn.o",
849 },816 },
850 },817 },
851 .netbsd => switch (mode) {818 .netbsd => switch (mode) {
852 .dynamic_lib => .{819 .dynamic_lib => .{
853 .crti = "crti.o",
854 .crtbegin = "crtbeginS.o",820 .crtbegin = "crtbeginS.o",
855 .crtend = "crtendS.o",821 .crtend = "crtendS.o",
856 .crtn = "crtn.o",
857 },822 },
858 .dynamic_exe => .{823 .dynamic_exe => .{
859 .crt0 = "crt0.o",824 .crt0 = "crt0.o",
860 .crti = "crti.o",
861 .crtbegin = "crtbegin.o",825 .crtbegin = "crtbegin.o",
862 .crtend = "crtend.o",826 .crtend = "crtend.o",
863 .crtn = "crtn.o",
864 },827 },
865 .dynamic_pie => .{828 .dynamic_pie => .{
866 .crt0 = "crt0.o",829 .crt0 = "crt0.o",
867 .crti = "crti.o",
868 .crtbegin = "crtbeginS.o",830 .crtbegin = "crtbeginS.o",
869 .crtend = "crtendS.o",831 .crtend = "crtendS.o",
870 .crtn = "crtn.o",
871 },832 },
872 .static_exe => .{833 .static_exe => .{
873 .crt0 = "crt0.o",834 .crt0 = "crt0.o",
874 .crti = "crti.o",
875 .crtbegin = "crtbeginT.o",835 .crtbegin = "crtbeginT.o",
876 .crtend = "crtend.o",836 .crtend = "crtend.o",
877 .crtn = "crtn.o",
878 },837 },
879 .static_pie => .{838 .static_pie => .{
880 .crt0 = "crt0.o",839 .crt0 = "crt0.o",
881 .crti = "crti.o",
882 .crtbegin = "crtbeginT.o",840 .crtbegin = "crtbeginT.o",
883 .crtend = "crtendS.o",841 .crtend = "crtendS.o",
884 .crtn = "crtn.o",
885 },842 },
886 },843 },
887 .openbsd => switch (mode) {844 .openbsd => switch (mode) {
...@@ -902,49 +859,34 @@ pub const CrtBasenames = struct {...@@ -902,49 +859,34 @@ pub const CrtBasenames = struct {
902 },859 },
903 .haiku => switch (mode) {860 .haiku => switch (mode) {
904 .dynamic_lib => .{861 .dynamic_lib => .{
905 .crti = "crti.o",
906 .crtbegin = "crtbeginS.o",862 .crtbegin = "crtbeginS.o",
907 .crtend = "crtendS.o",863 .crtend = "crtendS.o",
908 .crtn = "crtn.o",
909 },864 },
910 .dynamic_exe => .{865 .dynamic_exe => .{
911 .crt0 = "start_dyn.o",866 .crt0 = "start_dyn.o",
912 .crti = "crti.o",
913 .crtbegin = "crtbegin.o",867 .crtbegin = "crtbegin.o",
914 .crtend = "crtend.o",868 .crtend = "crtend.o",
915 .crtn = "crtn.o",
916 },869 },
917 .dynamic_pie => .{870 .dynamic_pie => .{
918 .crt0 = "start_dyn.o",871 .crt0 = "start_dyn.o",
919 .crti = "crti.o",
920 .crtbegin = "crtbeginS.o",872 .crtbegin = "crtbeginS.o",
921 .crtend = "crtendS.o",873 .crtend = "crtendS.o",
922 .crtn = "crtn.o",
923 },874 },
924 .static_exe => .{875 .static_exe => .{
925 .crt0 = "start_dyn.o",876 .crt0 = "start_dyn.o",
926 .crti = "crti.o",
927 .crtbegin = "crtbegin.o",877 .crtbegin = "crtbegin.o",
928 .crtend = "crtend.o",878 .crtend = "crtend.o",
929 .crtn = "crtn.o",
930 },879 },
931 .static_pie => .{880 .static_pie => .{
932 .crt0 = "start_dyn.o",881 .crt0 = "start_dyn.o",
933 .crti = "crti.o",
934 .crtbegin = "crtbeginS.o",882 .crtbegin = "crtbeginS.o",
935 .crtend = "crtendS.o",883 .crtend = "crtendS.o",
936 .crtn = "crtn.o",
937 },884 },
938 },885 },
939 .solaris, .illumos => switch (mode) {886 .solaris, .illumos => switch (mode) {
940 .dynamic_lib => .{887 .dynamic_lib => .{},
941 .crti = "crti.o",
942 .crtn = "crtn.o",
943 },
944 .dynamic_exe, .dynamic_pie => .{888 .dynamic_exe, .dynamic_pie => .{
945 .crt0 = "crt1.o",889 .crt0 = "crt1.o",
946 .crti = "crti.o",
947 .crtn = "crtn.o",
948 },890 },
949 .static_exe, .static_pie => .{},891 .static_exe, .static_pie => .{},
950 },892 },
...@@ -955,10 +897,8 @@ pub const CrtBasenames = struct {...@@ -955,10 +897,8 @@ pub const CrtBasenames = struct {
955897
956pub const CrtPaths = struct {898pub const CrtPaths = struct {
957 crt0: ?Path = null,899 crt0: ?Path = null,
958 crti: ?Path = null,
959 crtbegin: ?Path = null,900 crtbegin: ?Path = null,
960 crtend: ?Path = null,901 crtend: ?Path = null,
961 crtn: ?Path = null,
962};902};
963903
964pub fn resolveCrtPaths(904pub fn resolveCrtPaths(
...@@ -980,7 +920,6 @@ pub fn resolveCrtPaths(...@@ -980,7 +920,6 @@ pub fn resolveCrtPaths(
980 }) orelse true) "gcc80" else "gcc54";920 }) orelse true) "gcc80" else "gcc54";
981 return .{921 return .{
982 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,922 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
983 .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
984 .crtbegin = if (crt_basenames.crtbegin) |basename| .{923 .crtbegin = if (crt_basenames.crtbegin) |basename| .{
985 .root_dir = crt_dir_path.root_dir,924 .root_dir = crt_dir_path.root_dir,
986 .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),925 .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),
...@@ -989,7 +928,6 @@ pub fn resolveCrtPaths(...@@ -989,7 +928,6 @@ pub fn resolveCrtPaths(
989 .root_dir = crt_dir_path.root_dir,928 .root_dir = crt_dir_path.root_dir,
990 .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),929 .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),
991 } else null,930 } else null,
992 .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
993 };931 };
994 },932 },
995 .haiku => {933 .haiku => {
...@@ -999,19 +937,15 @@ pub fn resolveCrtPaths(...@@ -999,19 +937,15 @@ pub fn resolveCrtPaths(
999 };937 };
1000 return .{938 return .{
1001 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,939 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
1002 .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
1003 .crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null,940 .crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null,
1004 .crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null,941 .crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null,
1005 .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
1006 };942 };
1007 },943 },
1008 else => {944 else => {
1009 return .{945 return .{
1010 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,946 .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
1011 .crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
1012 .crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null,947 .crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null,
1013 .crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null,948 .crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null,
1014 .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
1015 };949 };
1016 },950 },
1017 }951 }
src/Compilation.zig-16
...@@ -801,8 +801,6 @@ pub const MiscTask = enum {...@@ -801,8 +801,6 @@ pub const MiscTask = enum {
801 docs_copy,801 docs_copy,
802 docs_wasm,802 docs_wasm,
803803
804 @"musl crti.o",
805 @"musl crtn.o",
806 @"musl crt1.o",804 @"musl crt1.o",
807 @"musl rcrt1.o",805 @"musl rcrt1.o",
808 @"musl Scrt1.o",806 @"musl Scrt1.o",
...@@ -817,8 +815,6 @@ pub const MiscTask = enum {...@@ -817,8 +815,6 @@ pub const MiscTask = enum {
817 @"libwasi-emulated-mman.a",815 @"libwasi-emulated-mman.a",
818 @"libwasi-emulated-signal.a",816 @"libwasi-emulated-signal.a",
819817
820 @"glibc crti.o",
821 @"glibc crtn.o",
822 @"glibc Scrt1.o",818 @"glibc Scrt1.o",
823 @"glibc libc_nonshared.a",819 @"glibc libc_nonshared.a",
824 @"glibc shared object",820 @"glibc shared object",
...@@ -1807,11 +1803,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1807,11 +1803,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1807 } else if (target.isMusl() and !target.isWasm()) {1803 } else if (target.isMusl() and !target.isWasm()) {
1808 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1804 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18091805
1810 if (musl.needsCrtiCrtn(target)) {
1811 comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crti_o)] = true;
1812 comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crtn_o)] = true;
1813 comp.remaining_prelink_tasks += 2;
1814 }
1815 if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {1806 if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {
1816 comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true;1807 comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true;
1817 comp.remaining_prelink_tasks += 1;1808 comp.remaining_prelink_tasks += 1;
...@@ -1824,11 +1815,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1824,11 +1815,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1824 } else if (target.isGnuLibC()) {1815 } else if (target.isGnuLibC()) {
1825 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;1816 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18261817
1827 if (glibc.needsCrtiCrtn(target)) {
1828 comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crti_o)] = true;
1829 comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crtn_o)] = true;
1830 comp.remaining_prelink_tasks += 2;
1831 }
1832 if (glibc.needsCrt0(comp.config.output_mode)) |f| {1818 if (glibc.needsCrt0(comp.config.output_mode)) |f| {
1833 comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true;1819 comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true;
1834 comp.remaining_prelink_tasks += 1;1820 comp.remaining_prelink_tasks += 1;
...@@ -6757,10 +6743,8 @@ fn getCrtPathsInner(...@@ -6757,10 +6743,8 @@ fn getCrtPathsInner(
67576743
6758 return .{6744 return .{
6759 .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null,6745 .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null,
6760 .crti = if (basenames.crti) |basename| try crtFilePath(crt_files, basename) else null,
6761 .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null,6746 .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null,
6762 .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null,6747 .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null,
6763 .crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null,
6764 };6748 };
6765}6749}
67666750
src/glibc.zig+5-95
...@@ -156,24 +156,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI...@@ -156,24 +156,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI
156 return abi;156 return abi;
157}157}
158158
159fn useElfInitFini(target: std.Target) bool {
160 // Legacy architectures use _init/_fini.
161 return switch (target.cpu.arch) {
162 .arm, .armeb => true,
163 .aarch64, .aarch64_be => true,
164 .m68k => true,
165 .mips, .mipsel, .mips64, .mips64el => true,
166 .powerpc, .powerpcle, .powerpc64, .powerpc64le => true,
167 .s390x => true,
168 .sparc, .sparc64 => true,
169 .x86, .x86_64 => true,
170 else => false,
171 };
172}
173
174pub const CrtFile = enum {159pub const CrtFile = enum {
175 crti_o,
176 crtn_o,
177 scrt1_o,160 scrt1_o,
178 libc_nonshared_a,161 libc_nonshared_a,
179};162};
...@@ -201,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -201,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
201 // waste computation and create false negatives.184 // waste computation and create false negatives.
202185
203 switch (crt_file) {186 switch (crt_file) {
204 .crti_o => {
205 var args = std.ArrayList([]const u8).init(arena);
206 try add_include_dirs(comp, arena, &args);
207 try args.appendSlice(&[_][]const u8{
208 "-D_LIBC_REENTRANT",
209 "-include",
210 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
211 "-DMODULE_NAME=libc",
212 "-Wno-nonportable-include-path",
213 "-include",
214 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
215 "-DTOP_NAMESPACE=glibc",
216 "-DASSEMBLER",
217 "-Wa,--noexecstack",
218 });
219 var files = [_]Compilation.CSourceFile{
220 .{
221 .src_path = try start_asm_path(comp, arena, "crti.S"),
222 .cache_exempt_flags = args.items,
223 .owner = comp.root_mod,
224 },
225 };
226 return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files, .{});
227 },
228 .crtn_o => {
229 var args = std.ArrayList([]const u8).init(arena);
230 try add_include_dirs(comp, arena, &args);
231 try args.appendSlice(&[_][]const u8{
232 "-D_LIBC_REENTRANT",
233 "-DMODULE_NAME=libc",
234 "-include",
235 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
236 "-DTOP_NAMESPACE=glibc",
237 "-DASSEMBLER",
238 "-Wa,--noexecstack",
239 });
240 var files = [_]Compilation.CSourceFile{
241 .{
242 .src_path = try start_asm_path(comp, arena, "crtn.S"),
243 .cache_exempt_flags = args.items,
244 .owner = undefined,
245 },
246 };
247 return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files, .{});
248 },
249 .scrt1_o => {187 .scrt1_o => {
250 const start_o: Compilation.CSourceFile = blk: {188 const start_o: Compilation.CSourceFile = blk: {
251 var args = std.ArrayList([]const u8).init(arena);189 var args = std.ArrayList([]const u8).init(arena);
...@@ -383,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -383,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
383 });321 });
384 try add_include_dirs(comp, arena, &args);322 try add_include_dirs(comp, arena, &args);
385323
386 if (!useElfInitFini(target)) {324 try args.append("-DNO_INITFINI");
387 try args.append("-DNO_INITFINI");
388 }
389325
390 if (target.cpu.arch == .x86) {326 if (target.cpu.arch == .x86) {
391 // This prevents i386/sysdep.h from trying to do some327 // This prevents i386/sysdep.h from trying to do some
...@@ -432,32 +368,15 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![...@@ -432,32 +368,15 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![
432 try result.appendSlice(comp.zig_lib_directory.path.?);368 try result.appendSlice(comp.zig_lib_directory.path.?);
433 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);369 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
434 if (is_sparc) {370 if (is_sparc) {
435 if (mem.eql(u8, basename, "crti.S") or mem.eql(u8, basename, "crtn.S")) {371 if (is_64) {
436 try result.appendSlice("sparc");372 try result.appendSlice("sparc" ++ s ++ "sparc64");
437 } else {373 } else {
438 if (is_64) {374 try result.appendSlice("sparc" ++ s ++ "sparc32");
439 try result.appendSlice("sparc" ++ s ++ "sparc64");
440 } else {
441 try result.appendSlice("sparc" ++ s ++ "sparc32");
442 }
443 }375 }
444 } else if (arch.isArm()) {376 } else if (arch.isArm()) {
445 try result.appendSlice("arm");377 try result.appendSlice("arm");
446 } else if (arch.isMIPS()) {378 } else if (arch.isMIPS()) {
447 if (!mem.eql(u8, basename, "crti.S") and !mem.eql(u8, basename, "crtn.S")) {379 try result.appendSlice("mips");
448 try result.appendSlice("mips");
449 } else {
450 if (is_64) {
451 const abi_dir = if (comp.getTarget().abi == .gnuabin32)
452 "n32"
453 else
454 "n64";
455 try result.appendSlice("mips" ++ s ++ "mips64" ++ s);
456 try result.appendSlice(abi_dir);
457 } else {
458 try result.appendSlice("mips" ++ s ++ "mips32");
459 }
460 }
461 } else if (arch == .x86_64) {380 } else if (arch == .x86_64) {
462 try result.appendSlice("x86_64");381 try result.appendSlice("x86_64");
463 } else if (arch == .x86) {382 } else if (arch == .x86) {
...@@ -1366,15 +1285,6 @@ fn buildSharedLib(...@@ -1366,15 +1285,6 @@ fn buildSharedLib(
1366 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);1285 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
1367}1286}
13681287
1369// Return true if glibc has crti/crtn sources for that architecture.
1370pub fn needsCrtiCrtn(target: std.Target) bool {
1371 return switch (target.cpu.arch) {
1372 .riscv32, .riscv64 => false,
1373 .loongarch64 => false,
1374 else => true,
1375 };
1376}
1377
1378pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {1288pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
1379 return switch (output_mode) {1289 return switch (output_mode) {
1380 .Obj, .Lib => null,1290 .Obj, .Lib => null,
src/link/Elf.zig-2
...@@ -1869,7 +1869,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s...@@ -1869,7 +1869,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
1869 // csu prelude1869 // csu prelude
1870 const csu = try comp.getCrtPaths(arena);1870 const csu = try comp.getCrtPaths(arena);
1871 if (csu.crt0) |p| try argv.append(try p.toString(arena));1871 if (csu.crt0) |p| try argv.append(try p.toString(arena));
1872 if (csu.crti) |p| try argv.append(try p.toString(arena));
1873 if (csu.crtbegin) |p| try argv.append(try p.toString(arena));1872 if (csu.crtbegin) |p| try argv.append(try p.toString(arena));
18741873
1875 for (self.rpath_table.keys()) |rpath| {1874 for (self.rpath_table.keys()) |rpath| {
...@@ -2061,7 +2060,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s...@@ -2061,7 +2060,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
20612060
2062 // crt postlude2061 // crt postlude
2063 if (csu.crtend) |p| try argv.append(try p.toString(arena));2062 if (csu.crtend) |p| try argv.append(try p.toString(arena));
2064 if (csu.crtn) |p| try argv.append(try p.toString(arena));
20652063
2066 if (self.base.allow_shlib_undefined) {2064 if (self.base.allow_shlib_undefined) {
2067 try argv.append("--allow-shlib-undefined");2065 try argv.append("--allow-shlib-undefined");
src/musl.zig-51
...@@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig");...@@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig");
9const build_options = @import("build_options");9const build_options = @import("build_options");
1010
11pub const CrtFile = enum {11pub const CrtFile = enum {
12 crti_o,
13 crtn_o,
14 crt1_o,12 crt1_o,
15 rcrt1_o,13 rcrt1_o,
16 scrt1_o,14 scrt1_o,
...@@ -30,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -30,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
30 const arena = arena_allocator.allocator();28 const arena = arena_allocator.allocator();
3129
32 switch (in_crt_file) {30 switch (in_crt_file) {
33 .crti_o => {
34 var args = std.ArrayList([]const u8).init(arena);
35 try addCcArgs(comp, arena, &args, false);
36 var files = [_]Compilation.CSourceFile{
37 .{
38 .src_path = try start_asm_path(comp, arena, "crti.s"),
39 .extra_flags = args.items,
40 .owner = undefined,
41 },
42 };
43 return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{
44 .function_sections = true,
45 .data_sections = true,
46 .omit_frame_pointer = true,
47 .no_builtin = true,
48 });
49 },
50 .crtn_o => {
51 var args = std.ArrayList([]const u8).init(arena);
52 try addCcArgs(comp, arena, &args, false);
53 var files = [_]Compilation.CSourceFile{
54 .{
55 .src_path = try start_asm_path(comp, arena, "crtn.s"),
56 .extra_flags = args.items,
57 .owner = undefined,
58 },
59 };
60 return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{
61 .function_sections = true,
62 .data_sections = true,
63 .omit_frame_pointer = true,
64 .no_builtin = true,
65 });
66 },
67 .crt1_o => {31 .crt1_o => {
68 var args = std.ArrayList([]const u8).init(arena);32 var args = std.ArrayList([]const u8).init(arena);
69 try addCcArgs(comp, arena, &args, false);33 try addCcArgs(comp, arena, &args, false);
...@@ -329,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro...@@ -329,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
329 }293 }
330}294}
331295
332/// Return true if musl has arch-specific crti/crtn sources.
333/// See lib/libc/musl/crt/ARCH/crt?.s .
334pub fn needsCrtiCrtn(target: std.Target) bool {
335 return switch (target.cpu.arch) {
336 .loongarch64,
337 .m68k,
338 .riscv32,
339 .riscv64,
340 .wasm32,
341 .wasm64,
342 => false,
343 else => true,
344 };
345}
346
347pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {296pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
348 return switch (output_mode) {297 return switch (output_mode) {
349 .Obj, .Lib => null,298 .Obj, .Lib => null,
test/link/elf.zig-4
...@@ -1,7 +1,3 @@...@@ -1,7 +1,3 @@
1//! Here we test our ELF linker for correctness and functionality.
2//! Currently, we support linking x86_64 Linux, but in the future we
3//! will progressively relax those to exercise more combinations.
4
5pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {1pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
6 _ = build_opts;2 _ = build_opts;
7 const elf_step = b.step("test-elf", "Run ELF tests");3 const elf_step = b.step("test-elf", "Run ELF tests");