From f5485a52bcd7495fb2be234695b4cea809f60581 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 20 Jan 2025 17:16:36 -0800 Subject: [PATCH] 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. --- lib/libc/glibc/sysdeps/aarch64/crti.S | 103 ----------- lib/libc/glibc/sysdeps/aarch64/crtn.S | 54 ------ lib/libc/glibc/sysdeps/alpha/crti.S | 101 ----------- lib/libc/glibc/sysdeps/alpha/crtn.S | 49 ------ lib/libc/glibc/sysdeps/arm/crti.S | 97 ----------- lib/libc/glibc/sysdeps/arm/crtn.S | 57 ------ lib/libc/glibc/sysdeps/hppa/crti.S | 162 ------------------ lib/libc/glibc/sysdeps/hppa/crtn.S | 66 ------- lib/libc/glibc/sysdeps/i386/crti.S | 86 ---------- lib/libc/glibc/sysdeps/i386/crtn.S | 47 ----- lib/libc/glibc/sysdeps/m68k/crti.S | 84 --------- lib/libc/glibc/sysdeps/m68k/crtn.S | 47 ----- lib/libc/glibc/sysdeps/microblaze/crti.S | 90 ---------- lib/libc/glibc/sysdeps/microblaze/crtn.S | 51 ------ lib/libc/glibc/sysdeps/mips/mips32/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips32/crtn.S | 59 ------- lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S | 61 ------- lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S | 102 ----------- lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S | 61 ------- .../glibc/sysdeps/powerpc/powerpc32/crti.S | 91 ---------- .../glibc/sysdeps/powerpc/powerpc32/crtn.S | 53 ------ .../glibc/sysdeps/powerpc/powerpc64/crti.S | 90 ---------- .../glibc/sysdeps/powerpc/powerpc64/crtn.S | 51 ------ lib/libc/glibc/sysdeps/s390/s390-32/crti.S | 104 ----------- lib/libc/glibc/sysdeps/s390/s390-32/crtn.S | 47 ----- lib/libc/glibc/sysdeps/s390/s390-64/crti.S | 93 ---------- lib/libc/glibc/sysdeps/s390/s390-64/crtn.S | 47 ----- lib/libc/glibc/sysdeps/sh/crti.S | 122 ------------- lib/libc/glibc/sysdeps/sh/crtn.S | 53 ------ lib/libc/glibc/sysdeps/sparc/crti.S | 95 ---------- lib/libc/glibc/sysdeps/sparc/crtn.S | 45 ----- lib/libc/glibc/sysdeps/x86_64/crti.S | 84 --------- lib/libc/glibc/sysdeps/x86_64/crtn.S | 45 ----- lib/libc/musl/crt/aarch64/crti.s | 13 -- lib/libc/musl/crt/aarch64/crtn.s | 7 - lib/libc/musl/crt/arm/crti.s | 15 -- lib/libc/musl/crt/arm/crtn.s | 9 - lib/libc/musl/crt/crti.c | 0 lib/libc/musl/crt/crtn.c | 0 lib/libc/musl/crt/i386/crti.s | 9 - lib/libc/musl/crt/i386/crtn.s | 7 - lib/libc/musl/crt/microblaze/crti.s | 13 -- lib/libc/musl/crt/microblaze/crtn.s | 9 - lib/libc/musl/crt/mips/crti.s | 19 -- lib/libc/musl/crt/mips/crtn.s | 15 -- lib/libc/musl/crt/mips64/crti.s | 17 -- lib/libc/musl/crt/mips64/crtn.s | 15 -- lib/libc/musl/crt/mipsn32/crti.s | 18 -- lib/libc/musl/crt/mipsn32/crtn.s | 14 -- lib/libc/musl/crt/or1k/crti.s | 11 -- lib/libc/musl/crt/or1k/crtn.s | 9 - lib/libc/musl/crt/powerpc/crti.s | 15 -- lib/libc/musl/crt/powerpc/crtn.s | 13 -- lib/libc/musl/crt/powerpc64/crti.s | 21 --- lib/libc/musl/crt/powerpc64/crtn.s | 13 -- lib/libc/musl/crt/s390x/crti.s | 17 -- lib/libc/musl/crt/s390x/crtn.s | 9 - lib/libc/musl/crt/sh/crti.s | 21 --- lib/libc/musl/crt/sh/crtn.s | 13 -- lib/libc/musl/crt/x32/crti.s | 9 - lib/libc/musl/crt/x32/crtn.s | 7 - lib/libc/musl/crt/x86_64/crti.s | 9 - lib/libc/musl/crt/x86_64/crtn.s | 7 - lib/std/zig/LibCInstallation.zig | 70 +------- src/Compilation.zig | 16 -- src/glibc.zig | 100 +---------- src/link/Elf.zig | 2 - src/musl.zig | 51 ------ test/link/elf.zig | 4 - 70 files changed, 7 insertions(+), 3191 deletions(-) delete mode 100644 lib/libc/glibc/sysdeps/aarch64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/aarch64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/alpha/crti.S delete mode 100644 lib/libc/glibc/sysdeps/alpha/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/arm/crti.S delete mode 100644 lib/libc/glibc/sysdeps/arm/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/hppa/crti.S delete mode 100644 lib/libc/glibc/sysdeps/hppa/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/i386/crti.S delete mode 100644 lib/libc/glibc/sysdeps/i386/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/m68k/crti.S delete mode 100644 lib/libc/glibc/sysdeps/m68k/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/microblaze/crti.S delete mode 100644 lib/libc/glibc/sysdeps/microblaze/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-32/crti.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-32/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/s390/s390-64/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/sh/crti.S delete mode 100644 lib/libc/glibc/sysdeps/sh/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/sparc/crti.S delete mode 100644 lib/libc/glibc/sysdeps/sparc/crtn.S delete mode 100644 lib/libc/glibc/sysdeps/x86_64/crti.S delete mode 100644 lib/libc/glibc/sysdeps/x86_64/crtn.S delete mode 100644 lib/libc/musl/crt/aarch64/crti.s delete mode 100644 lib/libc/musl/crt/aarch64/crtn.s delete mode 100644 lib/libc/musl/crt/arm/crti.s delete mode 100644 lib/libc/musl/crt/arm/crtn.s delete mode 100644 lib/libc/musl/crt/crti.c delete mode 100644 lib/libc/musl/crt/crtn.c delete mode 100644 lib/libc/musl/crt/i386/crti.s delete mode 100644 lib/libc/musl/crt/i386/crtn.s delete mode 100644 lib/libc/musl/crt/microblaze/crti.s delete mode 100644 lib/libc/musl/crt/microblaze/crtn.s delete mode 100644 lib/libc/musl/crt/mips/crti.s delete mode 100644 lib/libc/musl/crt/mips/crtn.s delete mode 100644 lib/libc/musl/crt/mips64/crti.s delete mode 100644 lib/libc/musl/crt/mips64/crtn.s delete mode 100644 lib/libc/musl/crt/mipsn32/crti.s delete mode 100644 lib/libc/musl/crt/mipsn32/crtn.s delete mode 100644 lib/libc/musl/crt/or1k/crti.s delete mode 100644 lib/libc/musl/crt/or1k/crtn.s delete mode 100644 lib/libc/musl/crt/powerpc/crti.s delete mode 100644 lib/libc/musl/crt/powerpc/crtn.s delete mode 100644 lib/libc/musl/crt/powerpc64/crti.s delete mode 100644 lib/libc/musl/crt/powerpc64/crtn.s delete mode 100644 lib/libc/musl/crt/s390x/crti.s delete mode 100644 lib/libc/musl/crt/s390x/crtn.s delete mode 100644 lib/libc/musl/crt/sh/crti.s delete mode 100644 lib/libc/musl/crt/sh/crtn.s delete mode 100644 lib/libc/musl/crt/x32/crti.s delete mode 100644 lib/libc/musl/crt/x32/crtn.s delete mode 100644 lib/libc/musl/crt/x86_64/crti.s delete mode 100644 lib/libc/musl/crt/x86_64/crtn.s diff --git a/lib/libc/glibc/sysdeps/aarch64/crti.S b/lib/libc/glibc/sysdeps/aarch64/crti.S deleted file mode 100644 index e54cb02123..0000000000 --- a/lib/libc/glibc/sysdeps/aarch64/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/aarch64/crtn.S b/lib/libc/glibc/sysdeps/aarch64/crtn.S deleted file mode 100644 index 3220e453ff..0000000000 --- a/lib/libc/glibc/sysdeps/aarch64/crtn.S +++ /dev/null @@ -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 - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .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 diff --git a/lib/libc/glibc/sysdeps/alpha/crti.S b/lib/libc/glibc/sysdeps/alpha/crti.S deleted file mode 100644 index 776c847ee1..0000000000 --- a/lib/libc/glibc/sysdeps/alpha/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/alpha/crtn.S b/lib/libc/glibc/sysdeps/alpha/crtn.S deleted file mode 100644 index a14b52f6c1..0000000000 --- a/lib/libc/glibc/sysdeps/alpha/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/arm/crti.S b/lib/libc/glibc/sysdeps/arm/crti.S deleted file mode 100644 index 9d6bbe977d..0000000000 --- a/lib/libc/glibc/sysdeps/arm/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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} diff --git a/lib/libc/glibc/sysdeps/arm/crtn.S b/lib/libc/glibc/sysdeps/arm/crtn.S deleted file mode 100644 index 0839e8713d..0000000000 --- a/lib/libc/glibc/sysdeps/arm/crtn.S +++ /dev/null @@ -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 - . */ - -/* Always build .init and .fini sections in ARM mode. */ -#define NO_THUMB -#include - -/* 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 diff --git a/lib/libc/glibc/sysdeps/hppa/crti.S b/lib/libc/glibc/sysdeps/hppa/crti.S deleted file mode 100644 index 46482224f4..0000000000 --- a/lib/libc/glibc/sysdeps/hppa/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/hppa/crtn.S b/lib/libc/glibc/sysdeps/hppa/crtn.S deleted file mode 100644 index bf5d8009b9..0000000000 --- a/lib/libc/glibc/sysdeps/hppa/crtn.S +++ /dev/null @@ -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 - . */ - -#include - -/* 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 diff --git a/lib/libc/glibc/sysdeps/i386/crti.S b/lib/libc/glibc/sysdeps/i386/crti.S deleted file mode 100644 index f9662eeb5a..0000000000 --- a/lib/libc/glibc/sysdeps/i386/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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) diff --git a/lib/libc/glibc/sysdeps/i386/crtn.S b/lib/libc/glibc/sysdeps/i386/crtn.S deleted file mode 100644 index 46f40ab554..0000000000 --- a/lib/libc/glibc/sysdeps/i386/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/m68k/crti.S b/lib/libc/glibc/sysdeps/m68k/crti.S deleted file mode 100644 index e52088799a..0000000000 --- a/lib/libc/glibc/sysdeps/m68k/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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) diff --git a/lib/libc/glibc/sysdeps/m68k/crtn.S b/lib/libc/glibc/sysdeps/m68k/crtn.S deleted file mode 100644 index 58e640e2c4..0000000000 --- a/lib/libc/glibc/sysdeps/m68k/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/microblaze/crti.S b/lib/libc/glibc/sysdeps/microblaze/crti.S deleted file mode 100644 index 58097a1b72..0000000000 --- a/lib/libc/glibc/sysdeps/microblaze/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/microblaze/crtn.S b/lib/libc/glibc/sysdeps/microblaze/crtn.S deleted file mode 100644 index 90b1aba1bd..0000000000 --- a/lib/libc/glibc/sysdeps/microblaze/crtn.S +++ /dev/null @@ -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 - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .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 diff --git a/lib/libc/glibc/sysdeps/mips/mips32/crti.S b/lib/libc/glibc/sysdeps/mips/mips32/crti.S deleted file mode 100644 index df1d91cf90..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips32/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 - -#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) diff --git a/lib/libc/glibc/sysdeps/mips/mips32/crtn.S b/lib/libc/glibc/sysdeps/mips/mips32/crtn.S deleted file mode 100644 index 4fd4c745d9..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips32/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,32 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S b/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S deleted file mode 100644 index 351655d08a..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 - -#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))) diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S b/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S deleted file mode 100644 index f9a6c7ee4c..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - addiu $sp,$sp,16 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S b/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S deleted file mode 100644 index 9726eb326a..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 - -#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))) diff --git a/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S b/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S deleted file mode 100644 index 2722b2812c..0000000000 --- a/lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 */ - jr $31 - daddiu $sp,$sp,16 - .set macro - .set reorder diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S b/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S deleted file mode 100644 index 6d0e17aa65..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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) diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S b/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S deleted file mode 100644 index 2a59a6cebc..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S +++ /dev/null @@ -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 - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .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 diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S b/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S deleted file mode 100644 index 71bdddfb3b..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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) diff --git a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S b/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S deleted file mode 100644 index 4e91231f2c..0000000000 --- a/lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S +++ /dev/null @@ -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 - . */ - -/* crtn.S puts function epilogues in the .init and .fini sections - corresponding to the prologues in crti.S. */ - -#include - - .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 diff --git a/lib/libc/glibc/sysdeps/s390/s390-32/crti.S b/lib/libc/glibc/sysdeps/s390/s390-32/crti.S deleted file mode 100644 index 47c5cb8781..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-32/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S b/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S deleted file mode 100644 index 911f35b586..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-32/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/s390/s390-64/crti.S b/lib/libc/glibc/sysdeps/s390/s390-64/crti.S deleted file mode 100644 index 6323b753be..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-64/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S b/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S deleted file mode 100644 index 9598f9e875..0000000000 --- a/lib/libc/glibc/sysdeps/s390/s390-64/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/sh/crti.S b/lib/libc/glibc/sysdeps/sh/crti.S deleted file mode 100644 index 9d6f77afa9..0000000000 --- a/lib/libc/glibc/sysdeps/sh/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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: diff --git a/lib/libc/glibc/sysdeps/sh/crtn.S b/lib/libc/glibc/sysdeps/sh/crtn.S deleted file mode 100644 index 55ad6f7864..0000000000 --- a/lib/libc/glibc/sysdeps/sh/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/sparc/crti.S b/lib/libc/glibc/sysdeps/sparc/crti.S deleted file mode 100644 index b3e73102f4..0000000000 --- a/lib/libc/glibc/sysdeps/sparc/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/sparc/crtn.S b/lib/libc/glibc/sysdeps/sparc/crtn.S deleted file mode 100644 index ea86c50f1b..0000000000 --- a/lib/libc/glibc/sysdeps/sparc/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/glibc/sysdeps/x86_64/crti.S b/lib/libc/glibc/sysdeps/x86_64/crti.S deleted file mode 100644 index 4d3f6767d4..0000000000 --- a/lib/libc/glibc/sysdeps/x86_64/crti.S +++ /dev/null @@ -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 - . */ - -/* 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 -#include - -#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 diff --git a/lib/libc/glibc/sysdeps/x86_64/crtn.S b/lib/libc/glibc/sysdeps/x86_64/crtn.S deleted file mode 100644 index 614f22e7f1..0000000000 --- a/lib/libc/glibc/sysdeps/x86_64/crtn.S +++ /dev/null @@ -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 - . */ - -/* 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 diff --git a/lib/libc/musl/crt/aarch64/crti.s b/lib/libc/musl/crt/aarch64/crti.s deleted file mode 100644 index 775df0ac04..0000000000 --- a/lib/libc/musl/crt/aarch64/crti.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/aarch64/crtn.s b/lib/libc/musl/crt/aarch64/crtn.s deleted file mode 100644 index 73cab6926b..0000000000 --- a/lib/libc/musl/crt/aarch64/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - ldp x29,x30,[sp],#16 - ret - -.section .fini - ldp x29,x30,[sp],#16 - ret diff --git a/lib/libc/musl/crt/arm/crti.s b/lib/libc/musl/crt/arm/crti.s deleted file mode 100644 index cccda3eaef..0000000000 --- a/lib/libc/musl/crt/arm/crti.s +++ /dev/null @@ -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} diff --git a/lib/libc/musl/crt/arm/crtn.s b/lib/libc/musl/crt/arm/crtn.s deleted file mode 100644 index dc020f92ef..0000000000 --- a/lib/libc/musl/crt/arm/crtn.s +++ /dev/null @@ -1,9 +0,0 @@ -.syntax unified - -.section .init - pop {r0,lr} - bx lr - -.section .fini - pop {r0,lr} - bx lr diff --git a/lib/libc/musl/crt/crti.c b/lib/libc/musl/crt/crti.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/libc/musl/crt/crtn.c b/lib/libc/musl/crt/crtn.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/libc/musl/crt/i386/crti.s b/lib/libc/musl/crt/i386/crti.s deleted file mode 100644 index d2682a20b0..0000000000 --- a/lib/libc/musl/crt/i386/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - sub $12,%esp - -.section .fini -.global _fini -_fini: - sub $12,%esp diff --git a/lib/libc/musl/crt/i386/crtn.s b/lib/libc/musl/crt/i386/crtn.s deleted file mode 100644 index f3b61e01bb..0000000000 --- a/lib/libc/musl/crt/i386/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - add $12,%esp - ret - -.section .fini - add $12,%esp - ret diff --git a/lib/libc/musl/crt/microblaze/crti.s b/lib/libc/musl/crt/microblaze/crti.s deleted file mode 100644 index ed1c2fa43a..0000000000 --- a/lib/libc/musl/crt/microblaze/crti.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/microblaze/crtn.s b/lib/libc/musl/crt/microblaze/crtn.s deleted file mode 100644 index 1e02c984e8..0000000000 --- a/lib/libc/musl/crt/microblaze/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/mips/crti.s b/lib/libc/musl/crt/mips/crti.s deleted file mode 100644 index 39dee38004..0000000000 --- a/lib/libc/musl/crt/mips/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/mips/crtn.s b/lib/libc/musl/crt/mips/crtn.s deleted file mode 100644 index 5146d83a0e..0000000000 --- a/lib/libc/musl/crt/mips/crtn.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder - -.section .init - lw $gp,24($sp) - lw $ra,28($sp) - # zig patch: j -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp,$sp,32 diff --git a/lib/libc/musl/crt/mips64/crti.s b/lib/libc/musl/crt/mips64/crti.s deleted file mode 100644 index c962dd099b..0000000000 --- a/lib/libc/musl/crt/mips64/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/mips64/crtn.s b/lib/libc/musl/crt/mips64/crtn.s deleted file mode 100644 index dc4dbb03ad..0000000000 --- a/lib/libc/musl/crt/mips64/crtn.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder - -.section .init - ld $gp,16($sp) - ld $ra,24($sp) - # zig patch: j -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - daddu $sp,$sp,32 diff --git a/lib/libc/musl/crt/mipsn32/crti.s b/lib/libc/musl/crt/mipsn32/crti.s deleted file mode 100644 index 14fa28d99d..0000000000 --- a/lib/libc/musl/crt/mipsn32/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/mipsn32/crtn.s b/lib/libc/musl/crt/mipsn32/crtn.s deleted file mode 100644 index 66f0c7a680..0000000000 --- a/lib/libc/musl/crt/mipsn32/crtn.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noreorder -.section .init - ld $gp, 16($sp) - ld $ra, 24($sp) - # zig patch: j -> jr 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 -> jr for https://github.com/ziglang/zig/issues/21315 - jr $ra - addu $sp, $sp, 32 diff --git a/lib/libc/musl/crt/or1k/crti.s b/lib/libc/musl/crt/or1k/crti.s deleted file mode 100644 index 7e7414596a..0000000000 --- a/lib/libc/musl/crt/or1k/crti.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/or1k/crtn.s b/lib/libc/musl/crt/or1k/crtn.s deleted file mode 100644 index 4185a02771..0000000000 --- a/lib/libc/musl/crt/or1k/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/powerpc/crti.s b/lib/libc/musl/crt/powerpc/crti.s deleted file mode 100644 index 60461ca4c2..0000000000 --- a/lib/libc/musl/crt/powerpc/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/powerpc/crtn.s b/lib/libc/musl/crt/powerpc/crtn.s deleted file mode 100644 index 2d14a6f0b7..0000000000 --- a/lib/libc/musl/crt/powerpc/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/powerpc64/crti.s b/lib/libc/musl/crt/powerpc64/crti.s deleted file mode 100644 index 9f712f0e07..0000000000 --- a/lib/libc/musl/crt/powerpc64/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/powerpc64/crtn.s b/lib/libc/musl/crt/powerpc64/crtn.s deleted file mode 100644 index a7a9f4a07d..0000000000 --- a/lib/libc/musl/crt/powerpc64/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/s390x/crti.s b/lib/libc/musl/crt/s390x/crti.s deleted file mode 100644 index f453205bd0..0000000000 --- a/lib/libc/musl/crt/s390x/crti.s +++ /dev/null @@ -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) diff --git a/lib/libc/musl/crt/s390x/crtn.s b/lib/libc/musl/crt/s390x/crtn.s deleted file mode 100644 index 06066dc994..0000000000 --- a/lib/libc/musl/crt/s390x/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/sh/crti.s b/lib/libc/musl/crt/sh/crti.s deleted file mode 100644 index d99bfd5c82..0000000000 --- a/lib/libc/musl/crt/sh/crti.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/sh/crtn.s b/lib/libc/musl/crt/sh/crtn.s deleted file mode 100644 index 958ce951b6..0000000000 --- a/lib/libc/musl/crt/sh/crtn.s +++ /dev/null @@ -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 diff --git a/lib/libc/musl/crt/x32/crti.s b/lib/libc/musl/crt/x32/crti.s deleted file mode 100644 index 4788968b22..0000000000 --- a/lib/libc/musl/crt/x32/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - push %rax - -.section .fini -.global _fini -_fini: - push %rax diff --git a/lib/libc/musl/crt/x32/crtn.s b/lib/libc/musl/crt/x32/crtn.s deleted file mode 100644 index 29198b7751..0000000000 --- a/lib/libc/musl/crt/x32/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - pop %rax - ret - -.section .fini - pop %rax - ret diff --git a/lib/libc/musl/crt/x86_64/crti.s b/lib/libc/musl/crt/x86_64/crti.s deleted file mode 100644 index 4788968b22..0000000000 --- a/lib/libc/musl/crt/x86_64/crti.s +++ /dev/null @@ -1,9 +0,0 @@ -.section .init -.global _init -_init: - push %rax - -.section .fini -.global _fini -_fini: - push %rax diff --git a/lib/libc/musl/crt/x86_64/crtn.s b/lib/libc/musl/crt/x86_64/crtn.s deleted file mode 100644 index 29198b7751..0000000000 --- a/lib/libc/musl/crt/x86_64/crtn.s +++ /dev/null @@ -1,7 +0,0 @@ -.section .init - pop %rax - ret - -.section .fini - pop %rax - ret diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 56bc388f5d..8a7c6a15e1 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -694,10 +694,8 @@ fn appendCcExe(args: *std.ArrayList([]const u8), skip_cc_env_var: bool) !void { /// `CsuPaths`. pub const CrtBasenames = struct { crt0: ?[]const u8 = null, - crti: ?[]const u8 = null, crtbegin: ?[]const u8 = null, crtend: ?[]const u8 = null, - crtn: ?[]const u8 = null, pub const GetArgs = struct { target: std.Target, @@ -751,137 +749,96 @@ pub const CrtBasenames = struct { return switch (target.os.tag) { .linux => switch (mode) { - .dynamic_lib => .{ - .crti = "crti.o", - .crtn = "crtn.o", - }, + .dynamic_lib => .{}, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "rcrt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, }, .dragonfly => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .freebsd => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt1.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "Scrt1.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .netbsd => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "crt0.o", - .crti = "crti.o", .crtbegin = "crtbeginT.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .openbsd => switch (mode) { @@ -902,49 +859,34 @@ pub const CrtBasenames = struct { }, .haiku => switch (mode) { .dynamic_lib => .{ - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .dynamic_exe => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .dynamic_pie => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, .static_exe => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbegin.o", .crtend = "crtend.o", - .crtn = "crtn.o", }, .static_pie => .{ .crt0 = "start_dyn.o", - .crti = "crti.o", .crtbegin = "crtbeginS.o", .crtend = "crtendS.o", - .crtn = "crtn.o", }, }, .solaris, .illumos => switch (mode) { - .dynamic_lib => .{ - .crti = "crti.o", - .crtn = "crtn.o", - }, + .dynamic_lib => .{}, .dynamic_exe, .dynamic_pie => .{ .crt0 = "crt1.o", - .crti = "crti.o", - .crtn = "crtn.o", }, .static_exe, .static_pie => .{}, }, @@ -955,10 +897,8 @@ pub const CrtBasenames = struct { pub const CrtPaths = struct { crt0: ?Path = null, - crti: ?Path = null, crtbegin: ?Path = null, crtend: ?Path = null, - crtn: ?Path = null, }; pub fn resolveCrtPaths( @@ -980,7 +920,6 @@ pub fn resolveCrtPaths( }) orelse true) "gcc80" else "gcc54"; return .{ .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| .{ .root_dir = crt_dir_path.root_dir, .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, .sub_path = try fs.path.join(arena, &.{ crt_dir_path.sub_path, gccv, basename }), } else null, - .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, }; }, .haiku => { @@ -999,19 +937,15 @@ pub fn resolveCrtPaths( }; return .{ .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, .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 => { return .{ .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, .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, }; }, } diff --git a/src/Compilation.zig b/src/Compilation.zig index dd91974a9c..a1fdc4fd1a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -801,8 +801,6 @@ pub const MiscTask = enum { docs_copy, docs_wasm, - @"musl crti.o", - @"musl crtn.o", @"musl crt1.o", @"musl rcrt1.o", @"musl Scrt1.o", @@ -817,8 +815,6 @@ pub const MiscTask = enum { @"libwasi-emulated-mman.a", @"libwasi-emulated-signal.a", - @"glibc crti.o", - @"glibc crtn.o", @"glibc Scrt1.o", @"glibc libc_nonshared.a", @"glibc shared object", @@ -1807,11 +1803,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil } else if (target.isMusl() and !target.isWasm()) { 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| { comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; @@ -1824,11 +1815,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil } else if (target.isGnuLibC()) { 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| { comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; @@ -6757,10 +6743,8 @@ fn getCrtPathsInner( return .{ .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, .crtend = if (basenames.crtend) |basename| try crtFilePath(crt_files, basename) else null, - .crtn = if (basenames.crtn) |basename| try crtFilePath(crt_files, basename) else null, }; } diff --git a/src/glibc.zig b/src/glibc.zig index ef0acff6ad..83d4439dcd 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -156,24 +156,7 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*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 { - crti_o, - crtn_o, scrt1_o, 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. 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 => { const start_o: Compilation.CSourceFile = blk: { 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); - if (!useElfInitFini(target)) { - try args.append("-DNO_INITFINI"); - } + try args.append("-DNO_INITFINI"); if (target.cpu.arch == .x86) { // 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(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s); if (is_sparc) { - if (mem.eql(u8, basename, "crti.S") or mem.eql(u8, basename, "crtn.S")) { - try result.appendSlice("sparc"); + if (is_64) { + try result.appendSlice("sparc" ++ s ++ "sparc64"); } else { - if (is_64) { - try result.appendSlice("sparc" ++ s ++ "sparc64"); - } else { - try result.appendSlice("sparc" ++ s ++ "sparc32"); - } + try result.appendSlice("sparc" ++ s ++ "sparc32"); } } else if (arch.isArm()) { try result.appendSlice("arm"); } else if (arch.isMIPS()) { - if (!mem.eql(u8, basename, "crti.S") and !mem.eql(u8, basename, "crtn.S")) { - 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"); - } - } + try result.appendSlice("mips"); } else if (arch == .x86_64) { try result.appendSlice("x86_64"); } else if (arch == .x86) { @@ -1366,15 +1285,6 @@ fn buildSharedLib( 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 { return switch (output_mode) { .Obj, .Lib => null, diff --git a/src/link/Elf.zig b/src/link/Elf.zig index ea2fa56a5d..957675fb0e 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1869,7 +1869,6 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s // csu prelude const csu = try comp.getCrtPaths(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)); 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 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) { try argv.append("--allow-shlib-undefined"); diff --git a/src/musl.zig b/src/musl.zig index e16b5601ab..511d55e08d 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -9,8 +9,6 @@ const Compilation = @import("Compilation.zig"); const build_options = @import("build_options"); pub const CrtFile = enum { - crti_o, - crtn_o, crt1_o, rcrt1_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(); 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 => { var args = std.ArrayList([]const u8).init(arena); 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 { return switch (output_mode) { .Obj, .Lib => null, diff --git a/test/link/elf.zig b/test/link/elf.zig index 5014d20c98..a64da3ad20 100644 --- a/test/link/elf.zig +++ b/test/link/elf.zig @@ -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 { _ = build_opts; const elf_step = b.step("test-elf", "Run ELF tests");