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.
This commit is contained in:
Andrew Kelley 2025-01-20 17:16:36 -08:00
parent 2391c460b1
commit f5485a52bc
70 changed files with 7 additions and 3191 deletions

View File

@ -1,103 +0,0 @@
/* Special .init and .fini section support for AArch64.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <sysdep.h>
#include <libc-symbols.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
#if PREINIT_FUNCTION_WEAK
.align 2
.type call_weak_fn, %function
call_weak_fn:
adrp x0, :got:PREINIT_FUNCTION
ldr PTR_REG (0), [x0, #:got_lo12:PREINIT_FUNCTION]
cbz x0, 1f
b PREINIT_FUNCTION
1:
RET
.size call_weak_fn, .-call_weak_fn
#endif
.section .init,"ax",%progbits
.align 2
.global _init
.hidden _init
.type _init, %function
_init:
#if HAVE_AARCH64_PAC_RET
PACIASP
#else
BTI_C
#endif
stp x29, x30, [sp, -16]!
mov x29, sp
#if PREINIT_FUNCTION_WEAK
bl call_weak_fn
#else
bl PREINIT_FUNCTION
#endif
.section .fini,"ax",%progbits
.align 2
.global _fini
.hidden _fini
.type _fini, %function
_fini:
#if HAVE_AARCH64_PAC_RET
PACIASP
#else
BTI_C
#endif
stp x29, x30, [sp, -16]!
mov x29, sp

View File

@ -1,54 +0,0 @@
/* Special .init and .fini section support for AArch64.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
#include <sysdep.h>
.section .init,"ax",%progbits
ldp x29, x30, [sp], 16
#if HAVE_AARCH64_PAC_RET
AUTIASP
#endif
RET
.section .fini,"ax",%progbits
ldp x29, x30, [sp], 16
#if HAVE_AARCH64_PAC_RET
AUTIASP
#endif
RET

View File

@ -1,101 +0,0 @@
/* Special .init and .fini section support for Alpha.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI.
This differs from what would be generated for ordinary code in that
we save and restore the GP within the function. In order for linker
relaxation to work, the value in the GP register on exit from a function
must be valid for the function entry point. Normally, a function is
contained within one object file and this is not an issue, provided
that the function reloads the gp after making any function calls.
However, _init and _fini are constructed from pieces of many object
files, all of which may have different GP values. So we must reload
the GP value from crti.o in crtn.o. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init, "ax", @progbits
.globl _init
.hidden _init
.type _init, @function
.usepv _init, std
_init:
ldgp $29, 0($27)
subq $30, 16, $30
#if PREINIT_FUNCTION_WEAK
lda $27, PREINIT_FUNCTION
#endif
stq $26, 0($30)
stq $29, 8($30)
#if PREINIT_FUNCTION_WEAK
beq $27, 1f
jsr $26, ($27), PREINIT_FUNCTION
ldq $29, 8($30)
1:
#else
bsr $26, PREINIT_FUNCTION !samegp
#endif
.p2align 3
.section .fini, "ax", @progbits
.globl _fini
.hidden _fini
.type _fini,@function
.usepv _fini,std
_fini:
ldgp $29, 0($27)
subq $30, 16, $30
stq $26, 0($30)
stq $29, 8($30)
.p2align 3

View File

@ -1,49 +0,0 @@
/* Special .init and .fini section support for Alpha.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init, "ax", @progbits
ldq $26, 0($30)
ldq $29, 8($30)
addq $30, 16, $30
ret
.section .fini, "ax", @progbits
ldq $26, 0($30)
ldq $29, 8($30)
addq $30, 16, $30
ret

View File

@ -1,97 +0,0 @@
/* Special .init and .fini section support for ARM.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
/* Always build .init and .fini sections in ARM mode. */
#define NO_THUMB
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
#if PREINIT_FUNCTION_WEAK
.p2align 2
.type call_weak_fn, %function
call_weak_fn:
ldr r3, .LGOT
ldr r2, .LGOT+4
.LPIC:
add r3, pc, r3
ldr r2, [r3, r2]
cmp r2, #0
bxeq lr
b PREINIT_FUNCTION
.p2align 2
.LGOT:
.word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
.word PREINIT_FUNCTION(GOT)
#endif
.section .init,"ax",%progbits
.p2align 2
.globl _init
.hidden _init
.type _init, %function
_init:
push {r3, lr}
#if PREINIT_FUNCTION_WEAK
bl call_weak_fn
#else
bl PREINIT_FUNCTION
#endif
.section .fini,"ax",%progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, %function
_fini:
push {r3, lr}

View File

@ -1,57 +0,0 @@
/* Special .init and .fini section support for ARM.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* Always build .init and .fini sections in ARM mode. */
#define NO_THUMB
#include <sysdep.h>
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",%progbits
#ifdef __ARM_ARCH_4T__
pop {r3, lr}
bx lr
#else
pop {r3, pc}
#endif
.section .fini,"ax",%progbits
#ifdef __ARM_ARCH_4T__
pop {r3, lr}
bx lr
#else
pop {r3, pc}
#endif

View File

@ -1,162 +0,0 @@
/* Special .init and .fini section support for HPPA
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
/* If we have working .init_array support, we want to keep the .init
section empty (apart from the mandatory prologue/epilogue. This
ensures that the default unwind conventions (return-pointer in b0,
frame state in ar.pfs, etc.) will do the Right Thing. To ensure
an empty .init section, we register gmon_initializer() via the
.init_array.
--davidm 02/10/29 */
#if PREINIT_FUNCTION_WEAK
/* This blob of assembly code is one simple C function:
static void
__attribute__ ((used))
gmon_initializer (void)
{
extern void weak_function __gmon_start__ (void);
if (__gmon_start__)
(*__gmon_start__)();
}
In a final executable, PLABEL32 relocations for function pointers are
resolved at link time. Typically, binutils/ld resolves __gmon_start__
using an external shared library. __gmon_start__ is always called if
it is found at link time. If __gmon_start__ is not found at runtime
due to a library update, then the function pointer will point at a null
function descriptor and calling it will cause a segmentation fault.
So, we call __canonicalize_funcptr_for_compare to obtain the canonicalized
address of __gmon_start__ and skip calling __gmon_start__ if it is zero.
*/
.type __canonicalize_funcptr_for_compare,@function
.type $$dyncall,@function
.section .data.rel.ro,"aw",@progbits
.align 4
.LC0:
.type __gmon_start__,@function
.word P%__gmon_start__
.text
.align 4
.type gmon_initializer,@function
gmon_initializer:
.PROC
.CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=4
.ENTRY
stw %r2,-20(%r30)
stwm %r4,64(%r30)
stw %r3,-60(%r30)
addil LT'.LC0,%r19
ldw RT'.LC0(%r1),%r28
ldw 0(%r28),%r3
comib,= 0,%r3,1f
copy %r19,%r4
stw %r19,-32(%r30)
bl __canonicalize_funcptr_for_compare,%r2
copy %r3,%r26
comib,= 0,%r28,1f
copy %r4,%r19
copy %r3,%r22
.CALL ARGW0=GR
bl $$dyncall,%r31
copy %r31,%r2
1:
ldw -84(%r30),%r2
ldw -60(%r30),%r3
bv %r0(%r2)
ldwm -64(%r30),%r4
.EXIT
.PROCEND
.size gmon_initializer, .-gmon_initializer
# undef PREINIT_FUNCTION
# define PREINIT_FUNCTION gmon_initializer
#endif
.section .init_array, "aw"
.word P% PREINIT_FUNCTION
/* _init prologue. */
.section .init, "ax", %progbits
.align 4
.globl _init
.hidden _init
.type _init,@function
_init:
stw %rp,-20(%sp)
stwm %r4,64(%sp)
stw %r19,-32(%sp)
/* _fini prologue. */
.section .fini,"ax",%progbits
.align 4
.globl _fini
.hidden _fini
.type _fini,@function
_fini:
stw %rp,-20(%sp)
stwm %r4,64(%sp)
stw %r19,-32(%sp)
copy %r19,%r4

View File

@ -1,66 +0,0 @@
/* Special .init and .fini section support for HPPA
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
#include <sysdep.h>
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init, "ax", @progbits
ldw -84(%sp),%rp
copy %r4,%r19
bv %r0(%rp)
_end_init:
ldwm -64(%sp),%r4
/* Our very own unwind info, because the assembler can't handle
functions split into two or more pieces. */
.section .PARISC.unwind
.extern _init
.word _init, _end_init
.byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
/* Here is the tail end of _fini. */
.section .fini, "ax", @progbits
ldw -84(%sp),%rp
copy %r4,%r19
bv %r0(%rp)
_end_fini:
ldwm -64(%sp),%r4
.section .PARISC.unwind
.extern _fini
.word _fini, _end_fini
.byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08

View File

@ -1,86 +0,0 @@
/* Special .init and .fini section support for x86.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
pushl %ebx
/* Maintain 16-byte stack alignment for called functions. */
subl $8, %esp
LOAD_PIC_REG (bx)
#if PREINIT_FUNCTION_WEAK
movl PREINIT_FUNCTION@GOT(%ebx), %eax
testl %eax, %eax
je .Lno_weak_fn
call *%eax
.Lno_weak_fn:
#else
call PREINIT_FUNCTION
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
pushl %ebx
subl $8, %esp
LOAD_PIC_REG (bx)

View File

@ -1,47 +0,0 @@
/* Special .init and .fini section support for x86.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
addl $8, %esp
popl %ebx
ret
.section .fini,"ax",@progbits
addl $8, %esp
popl %ebx
ret

View File

@ -1,84 +0,0 @@
/* Special .init and .fini section support for m68k.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.align 2
.globl _init
.hidden _init
.type _init, @function
_init:
link.w %fp, #0
move.l %a5, -(%sp)
LOAD_GOT (%a5)
#if PREINIT_FUNCTION_WEAK
tst.l PREINIT_FUNCTION@GOT(%a5)
jeq 1f
jbsr PREINIT_FUNCTION@PLTPC
1:
#else
jbsr PREINIT_FUNCTION
#endif
.section .fini,"ax",@progbits
.align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
link.w %fp, #0
move.l %a5, -(%sp)
LOAD_GOT (%a5)

View File

@ -1,47 +0,0 @@
/* Special .init and .fini section support for m68k.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
move.l -4(%fp), %a5
unlk %fp
rts
.section .fini,"ax",@progbits
move.l -4(%fp), %a5
unlk %fp
rts

View File

@ -1,90 +0,0 @@
/* Special .init and .fini section support for MicroBlaze.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.align 2
.globl _init
.hidden _init
.type _init, @function
_init:
addik r1,r1,-32
swi r20,r1,28
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
lwi r3,r20,PREINIT_FUNCTION@GOT
#if PREINIT_FUNCTION_WEAK
beqid r3,$Lno_weak_fn:
swi r15,r1,0
brlid r15,PREINIT_FUNCTION@PLT
$Lno_weak_fn:
#else
swi r15,r1,0
brald r15,r3
#endif
nop # Unfilled delay slot
.section .fini,"ax",@progbits
.align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
addik r1,r1,-32
swi r20,r1,28
swi r15,r1,0
mfs r20,rpc
addik r20,r20,_GLOBAL_OFFSET_TABLE_+8

View File

@ -1,51 +0,0 @@
/* Special .init and .fini section support for MicroBlaze.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
#include <sysdep.h>
.section .init,"ax",@progbits
lwi r15,r1,0
lwi r20,r1,28
rtsd r15,8
addik r1,r1,32
.section .fini,"ax",@progbits
lwi r15,r1,0
lwi r20,r1,28
rtsd r15,8
addik r1,r1,32

View File

@ -1,102 +0,0 @@
/* Special .init and .fini section support for MIPS (o32).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#ifdef __mips_micromips
# define JALR_RELOC R_MICROMIPS_JALR
#else
# define JALR_RELOC R_MIPS_JALR
#endif
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.set nomips16
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
.set noreorder
.cpload $25
.set reorder
addiu $sp,$sp,-32
.cprestore 16
sw $31,28($sp)
#if PREINIT_FUNCTION_WEAK
lw $2,%got(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
lw $25,%call16(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
lw $25,%got(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
.set noreorder
.cpload $25
.set reorder
addiu $sp,$sp,-32
.cprestore 16
sw $31,28($sp)

View File

@ -1,59 +0,0 @@
/* Special .init and .fini section support for MIPS (o32).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.set nomips16
.section .init,"ax",@progbits
lw $31,28($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
addiu $sp,$sp,32
.set macro
.set reorder
.section .fini,"ax",@progbits
lw $31,28($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
addiu $sp,$sp,32
.set macro
.set reorder

View File

@ -1,102 +0,0 @@
/* Special .init and .fini section support for MIPS (n32).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#ifdef __mips_micromips
# define JALR_RELOC R_MICROMIPS_JALR
#else
# define JALR_RELOC R_MIPS_JALR
#endif
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.set nomips16
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
addiu $sp,$sp,-16
sd $28,0($sp)
lui $28,%hi(%neg(%gp_rel(_init)))
addu $28,$28,$25
sd $31,8($sp)
addiu $28,$28,%lo(%neg(%gp_rel(_init)))
#if PREINIT_FUNCTION_WEAK
lw $2,%got_disp(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
lw $25,%call16(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
lw $25,%got_disp(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
addiu $sp,$sp,-16
sd $28,0($sp)
lui $28,%hi(%neg(%gp_rel(_fini)))
addu $28,$28,$25
sd $31,8($sp)
addiu $28,$28,%lo(%neg(%gp_rel(_fini)))

View File

@ -1,61 +0,0 @@
/* Special .init and .fini section support for MIPS (n32).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.set nomips16
.section .init,"ax",@progbits
ld $31,8($sp)
ld $28,0($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
addiu $sp,$sp,16
.set macro
.set reorder
.section .fini,"ax",@progbits
ld $31,8($sp)
ld $28,0($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
addiu $sp,$sp,16
.set macro
.set reorder

View File

@ -1,102 +0,0 @@
/* Special .init and .fini section support for MIPS (n64).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#ifdef __mips_micromips
# define JALR_RELOC R_MICROMIPS_JALR
#else
# define JALR_RELOC R_MIPS_JALR
#endif
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.set nomips16
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
daddiu $sp,$sp,-16
sd $28,0($sp)
lui $28,%hi(%neg(%gp_rel(_init)))
daddu $28,$28,$25
sd $31,8($sp)
daddiu $28,$28,%lo(%neg(%gp_rel(_init)))
#if PREINIT_FUNCTION_WEAK
ld $2,%got_disp(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
ld $25,%call16(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
ld $25,%got_disp(PREINIT_FUNCTION)($28)
.reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
daddiu $sp,$sp,-16
sd $28,0($sp)
lui $28,%hi(%neg(%gp_rel(_fini)))
daddu $28,$28,$25
sd $31,8($sp)
daddiu $28,$28,%lo(%neg(%gp_rel(_fini)))

View File

@ -1,61 +0,0 @@
/* Special .init and .fini section support for MIPS (n64).
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.set nomips16
.section .init,"ax",@progbits
ld $31,8($sp)
ld $28,0($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
daddiu $sp,$sp,16
.set macro
.set reorder
.section .fini,"ax",@progbits
ld $31,8($sp)
ld $28,0($sp)
.set noreorder
.set nomacro
/* zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315 */
jr $31
daddiu $sp,$sp,16
.set macro
.set reorder

View File

@ -1,91 +0,0 @@
/* Special .init and .fini section support for PowerPC.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.align 2
.globl _init
.hidden _init
.type _init, @function
_init:
stwu r1, -16(r1)
mflr r0
stw r0, 20(r1)
stw r30, 8(r1)
SETUP_GOT_ACCESS (r30, .Lgot_label_i)
addis r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@ha
addi r30, r30, _GLOBAL_OFFSET_TABLE_-.Lgot_label_i@l
#if PREINIT_FUNCTION_WEAK
lwz r0, PREINIT_FUNCTION@got(r30)
cmpwi cr7, r0, 0
beq+ cr7, 1f
bl PREINIT_FUNCTION@plt
1:
#else
bl PREINIT_FUNCTION@local
#endif
.section .fini,"ax",@progbits
.align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
stwu r1, -16(r1)
mflr r0
stw r0, 20(r1)
stw r30, 8(r1)
SETUP_GOT_ACCESS (r30, .Lgot_label_f)

View File

@ -1,53 +0,0 @@
/* Special .init and .fini section support for PowerPC.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
#include <sysdep.h>
.section .init,"ax",@progbits
lwz r0, 20(r1)
mtlr r0
lwz r30, 8(r1)
addi r1, r1, 16
blr
.section .fini,"ax",@progbits
lwz r0, 20(r1)
mtlr r0
lwz r30, 8(r1)
addi r1, r1, 16
blr

View File

@ -1,90 +0,0 @@
/* Special .init and .fini section support for PowerPC64.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
#if PREINIT_FUNCTION_WEAK
.section ".toc", "aw"
.LC0:
.tc PREINIT_FUNCTION[TC], PREINIT_FUNCTION
#endif
.section ".init", "ax", @progbits
ENTRY_2(_init)
.hidden _init
.align ALIGNARG (2)
BODY_LABEL (_init):
LOCALENTRY(_init)
mflr 0
std 0, FRAME_LR_SAVE(r1)
stdu r1, -FRAME_MIN_SIZE_PARM(r1)
#if PREINIT_FUNCTION_WEAK
addis r9, r2, .LC0@toc@ha
ld r0, .LC0@toc@l(r9)
cmpdi cr7, r0, 0
beq+ cr7, 1f
#endif
bl JUMPTARGET (PREINIT_FUNCTION)
nop
1:
.section ".fini", "ax", @progbits
ENTRY_2(_fini)
.hidden _fini
.align ALIGNARG (2)
BODY_LABEL (_fini):
LOCALENTRY(_fini)
mflr 0
std 0, FRAME_LR_SAVE(r1)
stdu r1, -FRAME_MIN_SIZE_PARM(r1)

View File

@ -1,51 +0,0 @@
/* Special .init and .fini section support for PowerPC64.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
#include <sysdep.h>
.section .init,"ax",@progbits
addi r1, r1, FRAME_MIN_SIZE_PARM
ld r0, FRAME_LR_SAVE(r1)
mtlr r0
blr
.section .fini,"ax",@progbits
addi r1, r1, FRAME_MIN_SIZE_PARM
ld r0, FRAME_LR_SAVE(r1)
mtlr r0
blr

View File

@ -1,104 +0,0 @@
/* Special .init and .fini section support for S/390.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.globl _init
.hidden _init
.type _init,@function
.align 4
_init:
stm %r6,%r15,24(%r15)
bras %r13,1f
0:
#if PREINIT_FUNCTION_WEAK
.long PREINIT_FUNCTION@GOT
#else
.long PREINIT_FUNCTION-0b
#endif
.long _GLOBAL_OFFSET_TABLE_-0b
1: lr %r1,%r15
ahi %r15,-96
st %r1,0(%r15)
l %r12,4(%r13)
ar %r12,%r13
l %r1,0(%r13)
#if PREINIT_FUNCTION_WEAK
l %r1,0(%r1,%r12)
ltr %r1,%r1
je 2f
#else
la %r1,0(%r1,%r13)
#endif
basr %r14,%r1
.align 4,0x07
2:
.section .fini,"ax",@progbits
.globl _fini
.hidden _fini
.type _fini,@function
.align 4
_fini:
stm %r6,%r15,24(%r15)
bras %r13,1f
0: .long _GLOBAL_OFFSET_TABLE_-0b
1: lr %r1,%r15
ahi %r15,-96
st %r1,0(%r15)
l %r12,0(%r13)
ar %r12,%r13
.align 4,0x07

View File

@ -1,47 +0,0 @@
/* Special .init and .fini section support for S/390.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
l %r4,152(%r15)
lm %r6,%r15,120(%r15)
br %r4
.section .fini,"ax",@progbits
l %r4,152(%r15)
lm %r6,%r15,120(%r15)
br %r4

View File

@ -1,93 +0,0 @@
/* Special .init and .fini section support for 64 bit S/390.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.align 4
.globl _init
.hidden _init
.type _init,@function
_init:
stmg %r6,%r15,48(%r15)
lgr %r1,%r15
aghi %r15,-160
stg %r1,0(%r15)
larl %r12,_GLOBAL_OFFSET_TABLE_
#if PREINIT_FUNCTION_WEAK
/* zig patch: GOTENT -> GOT. revert with llvm 20. */
larl %r1,PREINIT_FUNCTION@GOT
lg %r1,0(%r1)
ltgr %r1,%r1
je 1f
basr %r14,%r1
#else
brasl %r14,PREINIT_FUNCTION
#endif
.align 4,0x07
1:
.section .fini,"ax",@progbits
.align 4
.globl _fini
.hidden _fini
.type _fini,@function
_fini:
stmg %r6,%r15,48(%r15)
lg %r1,120(%r15)
aghi %r15,-160
stg %r1,0(%r15)
larl %r12,_GLOBAL_OFFSET_TABLE_
.align 4,0x07

View File

@ -1,47 +0,0 @@
/* Special .init and .fini section support for 64 bit S/390.
Copyright (C) 2001-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init
lg %r4,272(%r15)
lmg %r6,%r15,208(%r15)
br %r4
.section .fini
lg %r4,272(%r15)
lmg %r6,%r15,208(%r15)
br %r4

View File

@ -1,122 +0,0 @@
/* Special .init and .fini section support for SH.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.align 5
.global _init
.hidden _init
.type _init, @function
_init:
mov.l r12,@-r15
mova .L12,r0
mov.l .L12,r12
mov.l r14,@-r15
add r0,r12
sts.l pr,@-r15
#if PREINIT_FUNCTION_WEAK
mov.l .L13,r0
mov.l @(r0,r12),r1
tst r1,r1
bt/s .L8
mov r15,r14
mov.l .L14,r1
bsrf r1
.LPCS0:
nop
.L8:
#else
mova .L13,r0
mov.l .L13,r1
add r0,r1
jsr @r1
mov r15,r14
#endif
bra 1f
nop
.align 2
.L12:
.long _GLOBAL_OFFSET_TABLE_
#if PREINIT_FUNCTION_WEAK
.L13:
.long PREINIT_FUNCTION@GOT
.L14:
.long PREINIT_FUNCTION@PLT-(.LPCS0+2-(.))
#else
.L13:
.long PREINIT_FUNCTION@PLT
#endif
1:
.section .fini,"ax",@progbits
.align 5
.global _fini
.hidden _fini
.type _fini, @function
_fini:
mov.l r12,@-r15
mova .L19,r0
mov.l r14,@-r15
sts.l pr,@-r15
mov.l .L19,r12
mov r15,r14
add r0,r12
bra 0f
nop
.align 2
.L19:
.long _GLOBAL_OFFSET_TABLE_
0:

View File

@ -1,53 +0,0 @@
/* Special .init and .fini section support for SH.
Copyright (C) 2000-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
mov r14,r15
lds.l @r15+,pr
mov.l @r15+,r14
mov.l @r15+,r12
rts
nop
.section .fini,"ax",@progbits
mov r14,r15
lds.l @r15+,pr
mov.l @r15+,r14
mov.l @r15+,r12
rts
nop

View File

@ -1,95 +0,0 @@
/* Special .init and .fini section support for sparc.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
#ifdef __arch64__
#define STACKFRAME_SIZE 176
#define GOT_LOAD ldx
#else
#define STACKFRAME_SIZE 96
#define GOT_LOAD ld
#endif
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
save %sp, -STACKFRAME_SIZE, %sp
#if PREINIT_FUNCTION_WEAK
SETUP_PIC_REG(l7)
sethi %gdop_hix22(PREINIT_FUNCTION), %g1
xor %g1, %gdop_lox10(PREINIT_FUNCTION), %g1
GOT_LOAD [%l7 + %g1], %g1, %gdop(PREINIT_FUNCTION)
cmp %g1, 0
be 1f
nop
call PREINIT_FUNCTION
nop
1:
#else
call PREINIT_FUNCTION
nop
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
save %sp, -STACKFRAME_SIZE, %sp

View File

@ -1,45 +0,0 @@
/* Special .init and .fini section support for sparc.
Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
jmp %i7 + 8
restore
.section .fini,"ax",@progbits
jmp %i7 + 8
restore

View File

@ -1,84 +0,0 @@
/* Special .init and .fini section support for x86-64.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crti.S puts a function prologue at the beginning of the .init and
.fini sections and defines global symbols for those addresses, so
they can be called as functions. The symbols _init and _fini are
magic and cause the linker to emit DT_INIT and DT_FINI. */
#include <libc-symbols.h>
#include <sysdep.h>
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
#ifndef PREINIT_FUNCTION_WEAK
# define PREINIT_FUNCTION_WEAK 1
#endif
#if PREINIT_FUNCTION_WEAK
weak_extern (PREINIT_FUNCTION)
#else
.hidden PREINIT_FUNCTION
#endif
.section .init,"ax",@progbits
.p2align 2
.globl _init
.hidden _init
.type _init, @function
_init:
_CET_ENDBR
/* Maintain 16-byte stack alignment for called functions. */
subq $8, %rsp
#if PREINIT_FUNCTION_WEAK
movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax
testq %rax, %rax
je .Lno_weak_fn
call *%rax
.Lno_weak_fn:
#else
call PREINIT_FUNCTION
#endif
.section .fini,"ax",@progbits
.p2align 2
.globl _fini
.hidden _fini
.type _fini, @function
_fini:
_CET_ENDBR
subq $8, %rsp

View File

@ -1,45 +0,0 @@
/* Special .init and .fini section support for x86-64.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* crtn.S puts function epilogues in the .init and .fini sections
corresponding to the prologues in crti.S. */
.section .init,"ax",@progbits
addq $8, %rsp
ret
.section .fini,"ax",@progbits
addq $8, %rsp
ret

View File

@ -1,13 +0,0 @@
.section .init
.global _init
.type _init,%function
_init:
stp x29,x30,[sp,-16]!
mov x29,sp
.section .fini
.global _fini
.type _fini,%function
_fini:
stp x29,x30,[sp,-16]!
mov x29,sp

View File

@ -1,7 +0,0 @@
.section .init
ldp x29,x30,[sp],#16
ret
.section .fini
ldp x29,x30,[sp],#16
ret

View File

@ -1,15 +0,0 @@
.syntax unified
.section .init
.global _init
.type _init,%function
.align 2
_init:
push {r0,lr}
.section .fini
.global _fini
.type _fini,%function
.align 2
_fini:
push {r0,lr}

View File

@ -1,9 +0,0 @@
.syntax unified
.section .init
pop {r0,lr}
bx lr
.section .fini
pop {r0,lr}
bx lr

View File

View File

View File

@ -1,9 +0,0 @@
.section .init
.global _init
_init:
sub $12,%esp
.section .fini
.global _fini
_fini:
sub $12,%esp

View File

@ -1,7 +0,0 @@
.section .init
add $12,%esp
ret
.section .fini
add $12,%esp
ret

View File

@ -1,13 +0,0 @@
.section .init
.global _init
.align 2
_init:
addi r1, r1, -32
swi r15, r1, 0
.section .fini
.global _fini
.align 2
_fini:
addi r1, r1, -32
swi r15, r1, 0

View File

@ -1,9 +0,0 @@
.section .init
lwi r15, r1, 0
rtsd r15, 8
addi r1, r1, 32
.section .fini
lwi r15, r1, 0
rtsd r15, 8
addi r1, r1, 32

View File

@ -1,19 +0,0 @@
.set noreorder
.section .init
.global _init
.type _init,@function
.align 2
_init:
subu $sp,$sp,32
sw $gp,24($sp)
sw $ra,28($sp)
.section .fini
.global _fini
.type _fini,@function
.align 2
_fini:
subu $sp,$sp,32
sw $gp,24($sp)
sw $ra,28($sp)

View File

@ -1,15 +0,0 @@
.set noreorder
.section .init
lw $gp,24($sp)
lw $ra,28($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
addu $sp,$sp,32
.section .fini
lw $gp,24($sp)
lw $ra,28($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
addu $sp,$sp,32

View File

@ -1,17 +0,0 @@
.set noreorder
.section .init
.global _init
.align 3
_init:
dsubu $sp, $sp, 32
sd $gp, 16($sp)
sd $ra, 24($sp)
.section .fini
.global _fini
.align 3
_fini:
dsubu $sp, $sp, 32
sd $gp, 16($sp)
sd $ra, 24($sp)

View File

@ -1,15 +0,0 @@
.set noreorder
.section .init
ld $gp,16($sp)
ld $ra,24($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
daddu $sp,$sp,32
.section .fini
ld $gp,16($sp)
ld $ra,24($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
daddu $sp,$sp,32

View File

@ -1,18 +0,0 @@
.set noreorder
.section .init
.global _init
.type _init,@function
.align 2
_init:
subu $sp, $sp, 32
sd $gp, 16($sp)
sd $ra, 24($sp)
.section .fini
.global _fini
.type _fini,@function
.align 2
_fini:
subu $sp, $sp, 32
sd $gp, 16($sp)
sd $ra, 24($sp)

View File

@ -1,14 +0,0 @@
.set noreorder
.section .init
ld $gp, 16($sp)
ld $ra, 24($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
addu $sp, $sp, 32
.section .fini
ld $gp, 16($sp)
ld $ra, 24($sp)
# zig patch: j <reg> -> jr <reg> for https://github.com/ziglang/zig/issues/21315
jr $ra
addu $sp, $sp, 32

View File

@ -1,11 +0,0 @@
.section .init
.global _init
_init:
l.addi r1,r1,-4
l.sw 0(r1),r9
.section .fini
.global _fini
_fini:
l.addi r1,r1,-4
l.sw 0(r1),r9

View File

@ -1,9 +0,0 @@
.section .init
l.lwz r9,0(r1)
l.jr r9
l.addi r1,r1,4
.section .fini
l.lwz r9,0(r1)
l.jr r9
l.addi r1,r1,4

View File

@ -1,15 +0,0 @@
.section .init
.align 2
.global _init
_init:
stwu 1,-32(1)
mflr 0
stw 0,36(1)
.section .fini
.align 2
.global _fini
_fini:
stwu 1,-32(1)
mflr 0
stw 0,36(1)

View File

@ -1,13 +0,0 @@
.section .init
.align 2
lwz 0,36(1)
addi 1,1,32
mtlr 0
blr
.section .fini
.align 2
lwz 0,36(1)
addi 1,1,32
mtlr 0
blr

View File

@ -1,21 +0,0 @@
.section .init
.align 2
.global _init
_init:
addis 2, 12, .TOC.-_init@ha
addi 2, 2, .TOC.-_init@l
.localentry _init,.-_init
mflr 0
std 0, 16(1)
stdu 1,-32(1)
.section .fini
.align 2
.global _fini
_fini:
addis 2, 12, .TOC.-_fini@ha
addi 2, 2, .TOC.-_fini@l
.localentry _fini,.-_fini
mflr 0
std 0, 16(1)
stdu 1,-32(1)

View File

@ -1,13 +0,0 @@
.section .init
.align 2
addi 1, 1, 32
ld 0, 16(1)
mtlr 0
blr
.section .fini
.align 2
addi 1, 1, 32
ld 0, 16(1)
mtlr 0
blr

View File

@ -1,17 +0,0 @@
.section .init
.align 2
.global _init
_init:
stmg %r14, %r15, 112(%r15)
lgr %r0, %r15
aghi %r15, -160
stg %r0, 0(%r15)
.section .fini
.align 2
.global _fini
_fini:
stmg %r14, %r15, 112(%r15)
lgr %r0, %r15
aghi %r15, -160
stg %r0, 0(%r15)

View File

@ -1,9 +0,0 @@
.section .init
.align 2
lmg %r14, %r15, 272(%r15)
br %r14
.section .fini
.align 2
lmg %r14, %r15, 272(%r15)
br %r14

View File

@ -1,21 +0,0 @@
.section .init
.global _init
.type _init, @function
_init:
add #-4, r15
mov.l r12, @-r15
mov.l r14, @-r15
sts.l pr, @-r15
mov r15, r14
nop
.section .fini
.global _fini
.type _fini, @function
_fini:
add #-4, r15
mov.l r12, @-r15
mov.l r14, @-r15
sts.l pr, @-r15
mov r15, r14
nop

View File

@ -1,13 +0,0 @@
.section .init
lds.l @r15+, pr
mov.l @r15+, r14
mov.l @r15+, r12
rts
add #4, r15
.section .fini
lds.l @r15+, pr
mov.l @r15+, r14
mov.l @r15+, r12
rts
add #4, r15

View File

@ -1,9 +0,0 @@
.section .init
.global _init
_init:
push %rax
.section .fini
.global _fini
_fini:
push %rax

View File

@ -1,7 +0,0 @@
.section .init
pop %rax
ret
.section .fini
pop %rax
ret

View File

@ -1,9 +0,0 @@
.section .init
.global _init
_init:
push %rax
.section .fini
.global _fini
_fini:
push %rax

View File

@ -1,7 +0,0 @@
.section .init
pop %rax
ret
.section .fini
pop %rax
ret

View File

@ -694,10 +694,8 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void {
/// `CsuPaths`. /// `CsuPaths`.
pub const CrtBasenames = struct { pub const CrtBasenames = struct {
crt0: ?[]const u8 = null, crt0: ?[]const u8 = null,
crti: ?[]const u8 = null,
crtbegin: ?[]const u8 = null, crtbegin: ?[]const u8 = null,
crtend: ?[]const u8 = null, crtend: ?[]const u8 = null,
crtn: ?[]const u8 = null,
pub const GetArgs = struct { pub const GetArgs = struct {
target: std.Target, target: std.Target,
@ -751,137 +749,96 @@ pub const CrtBasenames = struct {
return switch (target.os.tag) { return switch (target.os.tag) {
.linux => switch (mode) { .linux => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{},
.crti = "crti.o",
.crtn = "crtn.o",
},
.dynamic_exe => .{ .dynamic_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
}, },
.dynamic_pie => .{ .dynamic_pie => .{
.crt0 = "Scrt1.o", .crt0 = "Scrt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
}, },
.static_exe => .{ .static_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
}, },
.static_pie => .{ .static_pie => .{
.crt0 = "rcrt1.o", .crt0 = "rcrt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
}, },
}, },
.dragonfly => switch (mode) { .dragonfly => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.dynamic_exe => .{ .dynamic_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.dynamic_pie => .{ .dynamic_pie => .{
.crt0 = "Scrt1.o", .crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.static_exe => .{ .static_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.static_pie => .{ .static_pie => .{
.crt0 = "Scrt1.o", .crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
}, },
.freebsd => switch (mode) { .freebsd => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.dynamic_exe => .{ .dynamic_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.dynamic_pie => .{ .dynamic_pie => .{
.crt0 = "Scrt1.o", .crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.static_exe => .{ .static_exe => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o", .crtbegin = "crtbeginT.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.static_pie => .{ .static_pie => .{
.crt0 = "Scrt1.o", .crt0 = "Scrt1.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
}, },
.netbsd => switch (mode) { .netbsd => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.dynamic_exe => .{ .dynamic_exe => .{
.crt0 = "crt0.o", .crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.dynamic_pie => .{ .dynamic_pie => .{
.crt0 = "crt0.o", .crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.static_exe => .{ .static_exe => .{
.crt0 = "crt0.o", .crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o", .crtbegin = "crtbeginT.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.static_pie => .{ .static_pie => .{
.crt0 = "crt0.o", .crt0 = "crt0.o",
.crti = "crti.o",
.crtbegin = "crtbeginT.o", .crtbegin = "crtbeginT.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
}, },
.openbsd => switch (mode) { .openbsd => switch (mode) {
@ -902,49 +859,34 @@ pub const CrtBasenames = struct {
}, },
.haiku => switch (mode) { .haiku => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.dynamic_exe => .{ .dynamic_exe => .{
.crt0 = "start_dyn.o", .crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.dynamic_pie => .{ .dynamic_pie => .{
.crt0 = "start_dyn.o", .crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
.static_exe => .{ .static_exe => .{
.crt0 = "start_dyn.o", .crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbegin.o", .crtbegin = "crtbegin.o",
.crtend = "crtend.o", .crtend = "crtend.o",
.crtn = "crtn.o",
}, },
.static_pie => .{ .static_pie => .{
.crt0 = "start_dyn.o", .crt0 = "start_dyn.o",
.crti = "crti.o",
.crtbegin = "crtbeginS.o", .crtbegin = "crtbeginS.o",
.crtend = "crtendS.o", .crtend = "crtendS.o",
.crtn = "crtn.o",
}, },
}, },
.solaris, .illumos => switch (mode) { .solaris, .illumos => switch (mode) {
.dynamic_lib => .{ .dynamic_lib => .{},
.crti = "crti.o",
.crtn = "crtn.o",
},
.dynamic_exe, .dynamic_pie => .{ .dynamic_exe, .dynamic_pie => .{
.crt0 = "crt1.o", .crt0 = "crt1.o",
.crti = "crti.o",
.crtn = "crtn.o",
}, },
.static_exe, .static_pie => .{}, .static_exe, .static_pie => .{},
}, },
@ -955,10 +897,8 @@ pub const CrtBasenames = struct {
pub const CrtPaths = struct { pub const CrtPaths = struct {
crt0: ?Path = null, crt0: ?Path = null,
crti: ?Path = null,
crtbegin: ?Path = null, crtbegin: ?Path = null,
crtend: ?Path = null, crtend: ?Path = null,
crtn: ?Path = null,
}; };
pub fn resolveCrtPaths( pub fn resolveCrtPaths(
@ -980,7 +920,6 @@ pub fn resolveCrtPaths(
}) orelse true) "gcc80" else "gcc54"; }) orelse true) "gcc80" else "gcc54";
return .{ return .{
.crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
.crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
.crtbegin = if (crt_basenames.crtbegin) |basename| .{ .crtbegin = if (crt_basenames.crtbegin) |basename| .{
.root_dir = crt_dir_path.root_dir, .root_dir = crt_dir_path.root_dir,
.sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),
@ -989,7 +928,6 @@ pub fn resolveCrtPaths(
.root_dir = crt_dir_path.root_dir, .root_dir = crt_dir_path.root_dir,
.sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }),
} else null, } else null,
.crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
}; };
}, },
.haiku => { .haiku => {
@ -999,19 +937,15 @@ pub fn resolveCrtPaths(
}; };
return .{ return .{
.crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
.crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
.crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try gcc_dir_path.join(arena, basename) else null,
.crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try gcc_dir_path.join(arena, basename) else null,
.crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
}; };
}, },
else => { else => {
return .{ return .{
.crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null, .crt0 = if (crt_basenames.crt0) |basename| try crt_dir_path.join(arena, basename) else null,
.crti = if (crt_basenames.crti) |basename| try crt_dir_path.join(arena, basename) else null,
.crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null, .crtbegin = if (crt_basenames.crtbegin) |basename| try crt_dir_path.join(arena, basename) else null,
.crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null, .crtend = if (crt_basenames.crtend) |basename| try crt_dir_path.join(arena, basename) else null,
.crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
}; };
}, },
} }

View File

@ -801,8 +801,6 @@ pub const MiscTask = enum {
docs_copy, docs_copy,
docs_wasm, docs_wasm,
@"musl crti.o",
@"musl crtn.o",
@"musl crt1.o", @"musl crt1.o",
@"musl rcrt1.o", @"musl rcrt1.o",
@"musl Scrt1.o", @"musl Scrt1.o",
@ -817,8 +815,6 @@ pub const MiscTask = enum {
@"libwasi-emulated-mman.a", @"libwasi-emulated-mman.a",
@"libwasi-emulated-signal.a", @"libwasi-emulated-signal.a",
@"glibc crti.o",
@"glibc crtn.o",
@"glibc Scrt1.o", @"glibc Scrt1.o",
@"glibc libc_nonshared.a", @"glibc libc_nonshared.a",
@"glibc shared object", @"glibc shared object",
@ -1807,11 +1803,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
} else if (target.isMusl() and !target.isWasm()) { } else if (target.isMusl() and !target.isWasm()) {
if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
if (musl.needsCrtiCrtn(target)) {
comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crti_o)] = true;
comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.crtn_o)] = true;
comp.remaining_prelink_tasks += 2;
}
if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| { if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {
comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true;
comp.remaining_prelink_tasks += 1; comp.remaining_prelink_tasks += 1;
@ -1824,11 +1815,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
} else if (target.isGnuLibC()) { } else if (target.isGnuLibC()) {
if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
if (glibc.needsCrtiCrtn(target)) {
comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crti_o)] = true;
comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.crtn_o)] = true;
comp.remaining_prelink_tasks += 2;
}
if (glibc.needsCrt0(comp.config.output_mode)) |f| { if (glibc.needsCrt0(comp.config.output_mode)) |f| {
comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true;
comp.remaining_prelink_tasks += 1; comp.remaining_prelink_tasks += 1;
@ -6757,10 +6743,8 @@ fn getCrtPathsInner(
return .{ return .{
.crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null, .crt0 = if (basenames.crt0) |basename| try crtFilePath(crt_files, basename) else null,
.crti = if (basenames.crti) |basename| try crtFilePath(crt_files, basename) else null,
.crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null, .crtbegin = if (basenames.crtbegin) |basename| try crtFilePath(crt_files, basename) else null,
.crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null, .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null,
.crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null,
}; };
} }

View File

@ -156,24 +156,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI
return abi; return abi;
} }
fn useElfInitFini(target: std.Target) bool {
// Legacy architectures use _init/_fini.
return switch (target.cpu.arch) {
.arm, .armeb => true,
.aarch64, .aarch64_be => true,
.m68k => true,
.mips, .mipsel, .mips64, .mips64el => true,
.powerpc, .powerpcle, .powerpc64, .powerpc64le => true,
.s390x => true,
.sparc, .sparc64 => true,
.x86, .x86_64 => true,
else => false,
};
}
pub const CrtFile = enum { pub const CrtFile = enum {
crti_o,
crtn_o,
scrt1_o, scrt1_o,
libc_nonshared_a, libc_nonshared_a,
}; };
@ -201,51 +184,6 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
// waste computation and create false negatives. // waste computation and create false negatives.
switch (crt_file) { switch (crt_file) {
.crti_o => {
var args = std.ArrayList([]const u8).init(arena);
try add_include_dirs(comp, arena, &args);
try args.appendSlice(&[_][]const u8{
"-D_LIBC_REENTRANT",
"-include",
try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
"-DMODULE_NAME=libc",
"-Wno-nonportable-include-path",
"-include",
try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
"-DTOP_NAMESPACE=glibc",
"-DASSEMBLER",
"-Wa,--noexecstack",
});
var files = [_]Compilation.CSourceFile{
.{
.src_path = try start_asm_path(comp, arena, "crti.S"),
.cache_exempt_flags = args.items,
.owner = comp.root_mod,
},
};
return comp.build_crt_file("crti", .Obj, .@"glibc crti.o", prog_node, &files, .{});
},
.crtn_o => {
var args = std.ArrayList([]const u8).init(arena);
try add_include_dirs(comp, arena, &args);
try args.appendSlice(&[_][]const u8{
"-D_LIBC_REENTRANT",
"-DMODULE_NAME=libc",
"-include",
try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
"-DTOP_NAMESPACE=glibc",
"-DASSEMBLER",
"-Wa,--noexecstack",
});
var files = [_]Compilation.CSourceFile{
.{
.src_path = try start_asm_path(comp, arena, "crtn.S"),
.cache_exempt_flags = args.items,
.owner = undefined,
},
};
return comp.build_crt_file("crtn", .Obj, .@"glibc crtn.o", prog_node, &files, .{});
},
.scrt1_o => { .scrt1_o => {
const start_o: Compilation.CSourceFile = blk: { const start_o: Compilation.CSourceFile = blk: {
var args = std.ArrayList([]const u8).init(arena); var args = std.ArrayList([]const u8).init(arena);
@ -383,9 +321,7 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
}); });
try add_include_dirs(comp, arena, &args); try add_include_dirs(comp, arena, &args);
if (!useElfInitFini(target)) {
try args.append("-DNO_INITFINI"); try args.append("-DNO_INITFINI");
}
if (target.cpu.arch == .x86) { if (target.cpu.arch == .x86) {
// This prevents i386/sysdep.h from trying to do some // 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) ![
try result.appendSlice(comp.zig_lib_directory.path.?); try result.appendSlice(comp.zig_lib_directory.path.?);
try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s); try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
if (is_sparc) { if (is_sparc) {
if (mem.eql(u8, basename, "crti.S") or mem.eql(u8, basename, "crtn.S")) {
try result.appendSlice("sparc");
} else {
if (is_64) { if (is_64) {
try result.appendSlice("sparc" ++ s ++ "sparc64"); try result.appendSlice("sparc" ++ s ++ "sparc64");
} else { } else {
try result.appendSlice("sparc" ++ s ++ "sparc32"); try result.appendSlice("sparc" ++ s ++ "sparc32");
} }
}
} else if (arch.isArm()) { } else if (arch.isArm()) {
try result.appendSlice("arm"); try result.appendSlice("arm");
} else if (arch.isMIPS()) { } else if (arch.isMIPS()) {
if (!mem.eql(u8, basename, "crti.S") and !mem.eql(u8, basename, "crtn.S")) {
try result.appendSlice("mips"); try result.appendSlice("mips");
} else {
if (is_64) {
const abi_dir = if (comp.getTarget().abi == .gnuabin32)
"n32"
else
"n64";
try result.appendSlice("mips" ++ s ++ "mips64" ++ s);
try result.appendSlice(abi_dir);
} else {
try result.appendSlice("mips" ++ s ++ "mips32");
}
}
} else if (arch == .x86_64) { } else if (arch == .x86_64) {
try result.appendSlice("x86_64"); try result.appendSlice("x86_64");
} else if (arch == .x86) { } else if (arch == .x86) {
@ -1366,15 +1285,6 @@ fn buildSharedLib(
try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node); try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
} }
// Return true if glibc has crti/crtn sources for that architecture.
pub fn needsCrtiCrtn(target: std.Target) bool {
return switch (target.cpu.arch) {
.riscv32, .riscv64 => false,
.loongarch64 => false,
else => true,
};
}
pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile { pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
return switch (output_mode) { return switch (output_mode) {
.Obj, .Lib => null, .Obj, .Lib => null,

View File

@ -1869,7 +1869,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
// csu prelude // csu prelude
const csu = try comp.getCrtPaths(arena); const csu = try comp.getCrtPaths(arena);
if (csu.crt0) |p| try argv.append(try p.toString(arena)); if (csu.crt0) |p| try argv.append(try p.toString(arena));
if (csu.crti) |p| try argv.append(try p.toString(arena));
if (csu.crtbegin) |p| try argv.append(try p.toString(arena)); if (csu.crtbegin) |p| try argv.append(try p.toString(arena));
for (self.rpath_table.keys()) |rpath| { for (self.rpath_table.keys()) |rpath| {
@ -2061,7 +2060,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
// crt postlude // crt postlude
if (csu.crtend) |p| try argv.append(try p.toString(arena)); if (csu.crtend) |p| try argv.append(try p.toString(arena));
if (csu.crtn) |p| try argv.append(try p.toString(arena));
if (self.base.allow_shlib_undefined) { if (self.base.allow_shlib_undefined) {
try argv.append("--allow-shlib-undefined"); try argv.append("--allow-shlib-undefined");

View File

@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig");
const build_options = @import("build_options"); const build_options = @import("build_options");
pub const CrtFile = enum { pub const CrtFile = enum {
crti_o,
crtn_o,
crt1_o, crt1_o,
rcrt1_o, rcrt1_o,
scrt1_o, scrt1_o,
@ -30,40 +28,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
const arena = arena_allocator.allocator(); const arena = arena_allocator.allocator();
switch (in_crt_file) { switch (in_crt_file) {
.crti_o => {
var args = std.ArrayList([]const u8).init(arena);
try addCcArgs(comp, arena, &args, false);
var files = [_]Compilation.CSourceFile{
.{
.src_path = try start_asm_path(comp, arena, "crti.s"),
.extra_flags = args.items,
.owner = undefined,
},
};
return comp.build_crt_file("crti", .Obj, .@"musl crti.o", prog_node, &files, .{
.function_sections = true,
.data_sections = true,
.omit_frame_pointer = true,
.no_builtin = true,
});
},
.crtn_o => {
var args = std.ArrayList([]const u8).init(arena);
try addCcArgs(comp, arena, &args, false);
var files = [_]Compilation.CSourceFile{
.{
.src_path = try start_asm_path(comp, arena, "crtn.s"),
.extra_flags = args.items,
.owner = undefined,
},
};
return comp.build_crt_file("crtn", .Obj, .@"musl crtn.o", prog_node, &files, .{
.function_sections = true,
.data_sections = true,
.omit_frame_pointer = true,
.no_builtin = true,
});
},
.crt1_o => { .crt1_o => {
var args = std.ArrayList([]const u8).init(arena); var args = std.ArrayList([]const u8).init(arena);
try addCcArgs(comp, arena, &args, false); try addCcArgs(comp, arena, &args, false);
@ -329,21 +293,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
} }
} }
/// Return true if musl has arch-specific crti/crtn sources.
/// See lib/libc/musl/crt/ARCH/crt?.s .
pub fn needsCrtiCrtn(target: std.Target) bool {
return switch (target.cpu.arch) {
.loongarch64,
.m68k,
.riscv32,
.riscv64,
.wasm32,
.wasm64,
=> false,
else => true,
};
}
pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile { pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
return switch (output_mode) { return switch (output_mode) {
.Obj, .Lib => null, .Obj, .Lib => null,

View File

@ -1,7 +1,3 @@
//! Here we test our ELF linker for correctness and functionality.
//! Currently, we support linking x86_64 Linux, but in the future we
//! will progressively relax those to exercise more combinations.
pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
_ = build_opts; _ = build_opts;
const elf_step = b.step("test-elf", "Run ELF tests"); const elf_step = b.step("test-elf", "Run ELF tests");