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/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/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/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-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/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/src/Compilation.zig b/src/Compilation.zig index 1260bc028f..b85033264a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -122,6 +122,10 @@ link_task_queue_postponed: std.ArrayListUnmanaged(link.Task) = .empty, /// the linker task thread. remaining_prelink_tasks: u32, +/// Set of work that can be represented by only flags to determine whether the +/// work is queued or not. +queued_jobs: QueuedJobs, + work_queues: [ len: { var len: usize = 0; @@ -193,10 +197,6 @@ stack_report: bool, debug_compiler_runtime_libs: bool, debug_compile_errors: bool, incremental: bool, -job_queued_compiler_rt_lib: bool = false, -job_queued_compiler_rt_obj: bool = false, -job_queued_fuzzer_lib: bool = false, -job_queued_update_builtin_zig: bool, alloc_failure_occurred: bool = false, last_update_was_cache_hit: bool = false, @@ -234,13 +234,13 @@ tsan_lib: ?CrtFile = null, /// and resolved before calling linker.flush(). libc_static_lib: ?CrtFile = null, /// Populated when we build the libcompiler_rt static library. A Job to build this is indicated -/// by setting `job_queued_compiler_rt_lib` and resolved before calling linker.flush(). +/// by setting `queued_jobs.compiler_rt_lib` and resolved before calling linker.flush(). compiler_rt_lib: ?CrtFile = null, /// Populated when we build the compiler_rt_obj object. A Job to build this is indicated -/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush(). +/// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush(). compiler_rt_obj: ?CrtFile = null, /// Populated when we build the libfuzzer static library. A Job to build this -/// is indicated by setting `job_queued_fuzzer_lib` and resolved before +/// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before /// calling linker.flush(). fuzzer_lib: ?CrtFile = null, @@ -284,6 +284,27 @@ file_system_inputs: ?*std.ArrayListUnmanaged(u8), /// This digest will be known after update() is called. digest: ?[Cache.bin_digest_len]u8 = null, +const QueuedJobs = struct { + compiler_rt_lib: bool = false, + compiler_rt_obj: bool = false, + fuzzer_lib: bool = false, + update_builtin_zig: bool, + musl_crt_file: [@typeInfo(musl.CrtFile).@"enum".fields.len]bool = @splat(false), + glibc_crt_file: [@typeInfo(glibc.CrtFile).@"enum".fields.len]bool = @splat(false), + /// one of WASI libc static objects + wasi_libc_crt_file: [@typeInfo(wasi_libc.CrtFile).@"enum".fields.len]bool = @splat(false), + /// one of the mingw-w64 static objects + mingw_crt_file: [@typeInfo(mingw.CrtFile).@"enum".fields.len]bool = @splat(false), + /// all of the glibc shared objects + glibc_shared_objects: bool = false, + /// libunwind.a, usually needed when linking libc + libunwind: bool = false, + libcxx: bool = false, + libcxxabi: bool = false, + libtsan: bool = false, + zig_libc: bool = false, +}; + pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size; pub const SemaError = Zcu.SemaError; @@ -377,26 +398,6 @@ const Job = union(enum) { /// Fully resolve the given `struct` or `union` type. resolve_type_fully: InternPool.Index, - /// one of the glibc static objects - glibc_crt_file: glibc.CrtFile, - /// all of the glibc shared objects - glibc_shared_objects, - /// one of the musl static objects - musl_crt_file: musl.CrtFile, - /// one of the mingw-w64 static objects - mingw_crt_file: mingw.CrtFile, - - /// libunwind.a, usually needed when linking libc - libunwind: void, - libcxx: void, - libcxxabi: void, - libtsan: void, - /// needed when not linking libc and using LLVM for code generation because it generates - /// calls to, for example, memcpy and memset. - zig_libc: void, - /// one of WASI libc static objects - wasi_libc_crt_file: wasi_libc.CrtFile, - /// The value is the index into `windows_libs`. windows_import_lib: usize, @@ -800,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", @@ -816,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", @@ -1512,7 +1509,9 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .framework_dirs = options.framework_dirs, .llvm_opt_bisect_limit = options.llvm_opt_bisect_limit, .skip_linker_dependencies = options.skip_linker_dependencies, - .job_queued_update_builtin_zig = have_zcu, + .queued_jobs = .{ + .update_builtin_zig = have_zcu, + }, .function_sections = options.function_sections, .data_sections = options.data_sections, .native_system_include_paths = options.native_system_include_paths, @@ -1804,64 +1803,44 @@ 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)) { - try comp.queueJobs(&[_]Job{ - .{ .musl_crt_file = .crti_o }, - .{ .musl_crt_file = .crtn_o }, - }); - comp.remaining_prelink_tasks += 2; - } if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| { - try comp.queueJobs(&.{.{ .musl_crt_file = f }}); + comp.queued_jobs.musl_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; } - try comp.queueJobs(&.{.{ .musl_crt_file = switch (comp.config.link_mode) { - .static => .libc_a, - .dynamic => .libc_so, - } }}); + switch (comp.config.link_mode) { + .static => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_a)] = true, + .dynamic => comp.queued_jobs.musl_crt_file[@intFromEnum(musl.CrtFile.libc_so)] = true, + } comp.remaining_prelink_tasks += 1; } else if (target.isGnuLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; - if (glibc.needsCrtiCrtn(target)) { - try comp.queueJobs(&[_]Job{ - .{ .glibc_crt_file = .crti_o }, - .{ .glibc_crt_file = .crtn_o }, - }); - comp.remaining_prelink_tasks += 2; - } if (glibc.needsCrt0(comp.config.output_mode)) |f| { - try comp.queueJobs(&.{.{ .glibc_crt_file = f }}); + comp.queued_jobs.glibc_crt_file[@intFromEnum(f)] = true; comp.remaining_prelink_tasks += 1; } - try comp.queueJobs(&[_]Job{ - .{ .glibc_shared_objects = {} }, - .{ .glibc_crt_file = .libc_nonshared_a }, - }); - comp.remaining_prelink_tasks += 1; + comp.queued_jobs.glibc_shared_objects = true; comp.remaining_prelink_tasks += glibc.sharedObjectsCount(&target); + + comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true; + comp.remaining_prelink_tasks += 1; } else if (target.isWasm() and target.os.tag == .wasi) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; for (comp.wasi_emulated_libs) |crt_file| { - try comp.queueJob(.{ - .wasi_libc_crt_file = crt_file, - }); - comp.remaining_prelink_tasks += 1; + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(crt_file)] = true; } - try comp.queueJobs(&[_]Job{ - .{ .wasi_libc_crt_file = wasi_libc.execModelCrtFile(comp.config.wasi_exec_model) }, - .{ .wasi_libc_crt_file = .libc_a }, - }); + comp.remaining_prelink_tasks += @intCast(comp.wasi_emulated_libs.len); + + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.execModelCrtFile(comp.config.wasi_exec_model))] = true; + comp.queued_jobs.wasi_libc_crt_file[@intFromEnum(wasi_libc.CrtFile.libc_a)] = true; comp.remaining_prelink_tasks += 2; } else if (target.isMinGW()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; - const crt_job: Job = .{ .mingw_crt_file = if (is_dyn_lib) .dllcrt2_o else .crt2_o }; - try comp.queueJobs(&.{ - .{ .mingw_crt_file = .mingw32_lib }, - crt_job, - }); + const main_crt_file: mingw.CrtFile = if (is_dyn_lib) .dllcrt2_o else .crt2_o; + comp.queued_jobs.mingw_crt_file[@intFromEnum(main_crt_file)] = true; + comp.queued_jobs.mingw_crt_file[@intFromEnum(mingw.CrtFile.mingw32_lib)] = true; comp.remaining_prelink_tasks += 2; // When linking mingw-w64 there are some import libs we always need. @@ -1873,7 +1852,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil else => return error.LibCUnavailable, } } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) { - try comp.queueJob(.{ .zig_libc = {} }); + comp.queued_jobs.zig_libc = true; comp.remaining_prelink_tasks += 1; } else { return error.LibCUnavailable; @@ -1886,18 +1865,22 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil for (0..count) |i| { try comp.queueJob(.{ .windows_import_lib = i }); } + // when integrating coff linker with prelink, the above + // queueJob will need to change into something else since those + // jobs are dispatched *after* the link_task_wait_group.wait() + // that happens when separateCodegenThreadOk() is false. } if (comp.wantBuildLibUnwindFromSource()) { - try comp.queueJob(.{ .libunwind = {} }); + comp.queued_jobs.libunwind = true; comp.remaining_prelink_tasks += 1; } if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.link_libcpp) { - try comp.queueJob(.libcxx); - try comp.queueJob(.libcxxabi); + comp.queued_jobs.libcxx = true; + comp.queued_jobs.libcxxabi = true; comp.remaining_prelink_tasks += 2; } if (build_options.have_llvm and is_exe_or_dyn_lib and comp.config.any_sanitize_thread) { - try comp.queueJob(.libtsan); + comp.queued_jobs.libtsan = true; comp.remaining_prelink_tasks += 1; } @@ -1916,20 +1899,20 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (comp.include_compiler_rt and capable_of_building_compiler_rt) { if (is_exe_or_dyn_lib) { log.debug("queuing a job to build compiler_rt_lib", .{}); - comp.job_queued_compiler_rt_lib = true; + comp.queued_jobs.compiler_rt_lib = true; comp.remaining_prelink_tasks += 1; } else if (output_mode != .Obj) { log.debug("queuing a job to build compiler_rt_obj", .{}); // In this case we are making a static library, so we ask // for a compiler-rt object to put in it. - comp.job_queued_compiler_rt_obj = true; + comp.queued_jobs.compiler_rt_obj = true; comp.remaining_prelink_tasks += 1; } } if (is_exe_or_dyn_lib and comp.config.any_fuzz and capable_of_building_compiler_rt) { log.debug("queuing a job to build libfuzzer", .{}); - comp.job_queued_fuzzer_lib = true; + comp.queued_jobs.fuzzer_lib = true; comp.remaining_prelink_tasks += 1; } } @@ -3712,21 +3695,70 @@ fn performAllTheWorkInner( work_queue_wait_group.spawnManager(workerDocsWasm, .{ comp, main_progress_node }); } - if (comp.job_queued_compiler_rt_lib) { - comp.job_queued_compiler_rt_lib = false; + if (testAndClear(&comp.queued_jobs.compiler_rt_lib)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node }); } - if (comp.job_queued_compiler_rt_obj) { - comp.job_queued_compiler_rt_obj = false; + if (testAndClear(&comp.queued_jobs.compiler_rt_obj)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node }); } - if (comp.job_queued_fuzzer_lib) { - comp.job_queued_fuzzer_lib = false; + if (testAndClear(&comp.queued_jobs.fuzzer_lib)) { comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); } + if (testAndClear(&comp.queued_jobs.glibc_shared_objects)) { + comp.link_task_wait_group.spawnManager(buildGlibcSharedObjects, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libunwind)) { + comp.link_task_wait_group.spawnManager(buildLibUnwind, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libcxx)) { + comp.link_task_wait_group.spawnManager(buildLibCxx, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libcxxabi)) { + comp.link_task_wait_group.spawnManager(buildLibCxxAbi, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.libtsan)) { + comp.link_task_wait_group.spawnManager(buildLibTsan, .{ comp, main_progress_node }); + } + + if (testAndClear(&comp.queued_jobs.zig_libc)) { + comp.link_task_wait_group.spawnManager(buildZigLibc, .{ comp, main_progress_node }); + } + + for (0..@typeInfo(musl.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.musl_crt_file[i])) { + const tag: musl.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildMuslCrtFile, .{ comp, tag, main_progress_node }); + } + } + + for (0..@typeInfo(glibc.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.glibc_crt_file[i])) { + const tag: glibc.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildGlibcCrtFile, .{ comp, tag, main_progress_node }); + } + } + + for (0..@typeInfo(wasi_libc.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.wasi_libc_crt_file[i])) { + const tag: wasi_libc.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildWasiLibcCrtFile, .{ comp, tag, main_progress_node }); + } + } + + for (0..@typeInfo(mingw.CrtFile).@"enum".fields.len) |i| { + if (testAndClear(&comp.queued_jobs.mingw_crt_file[i])) { + const tag: mingw.CrtFile = @enumFromInt(i); + comp.link_task_wait_group.spawnManager(buildMingwCrtFile, .{ comp, tag, main_progress_node }); + } + } + { const astgen_frame = tracy.namedFrame("astgen"); defer astgen_frame.end(); @@ -3741,8 +3773,8 @@ fn performAllTheWorkInner( // 1. to avoid race condition of zig processes truncating each other's builtin.zig files // 2. optimization; in the hot path it only incurs a stat() syscall, which happens // in the `astgen_wait_group`. - if (comp.job_queued_update_builtin_zig) b: { - comp.job_queued_update_builtin_zig = false; + if (comp.queued_jobs.update_builtin_zig) b: { + comp.queued_jobs.update_builtin_zig = false; if (comp.zcu == null) break :b; // TODO put all the modules in a flat array to make them easy to iterate. var seen: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .empty; @@ -3821,11 +3853,12 @@ fn performAllTheWorkInner( comp.link_task_wait_group.wait(); comp.link_task_wait_group.reset(); std.log.scoped(.link).debug("finished waiting for link_task_wait_group", .{}); + assert(comp.remaining_prelink_tasks == 0); } work: while (true) { for (&comp.work_queues) |*work_queue| if (work_queue.readItem()) |job| { - try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job, main_progress_node); + try processOneJob(@intFromEnum(Zcu.PerThread.Id.main), comp, job); continue :work; }; if (comp.zcu) |zcu| { @@ -3860,7 +3893,7 @@ pub fn queueJobs(comp: *Compilation, jobs: []const Job) !void { for (jobs) |job| try comp.queueJob(job); } -fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progress.Node) JobError!void { +fn processOneJob(tid: usize, comp: *Compilation, job: Job) JobError!void { switch (job) { .codegen_nav => |nav_index| { const zcu = comp.zcu.?; @@ -3956,56 +3989,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre error.AnalysisFail => return, }; }, - .glibc_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("glibc_crt_file"); - defer named_frame.end(); - - glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc CRT file: {s}", .{ - @errorName(err), - }); - }; - }, - .glibc_shared_objects => { - const named_frame = tracy.namedFrame("glibc_shared_objects"); - defer named_frame.end(); - - glibc.buildSharedObjects(comp, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .glibc_shared_objects, - "unable to build glibc shared objects: {s}", - .{@errorName(err)}, - ); - }; - }, - .musl_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("musl_crt_file"); - defer named_frame.end(); - - musl.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .musl_crt_file, - "unable to build musl CRT file: {s}", - .{@errorName(err)}, - ); - }; - }, - .mingw_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("mingw_crt_file"); - defer named_frame.end(); - - mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .mingw_crt_file, - "unable to build mingw-w64 CRT file {s}: {s}", - .{ @tagName(crt_file), @errorName(err) }, - ); - }; - }, .windows_import_lib => |index| { const named_frame = tracy.namedFrame("windows_import_lib"); defer named_frame.end(); @@ -4020,95 +4003,6 @@ fn processOneJob(tid: usize, comp: *Compilation, job: Job, prog_node: std.Progre ); }; }, - .libunwind => { - const named_frame = tracy.namedFrame("libunwind"); - defer named_frame.end(); - - libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libunwind, - "unable to build libunwind: {s}", - .{@errorName(err)}, - ), - }; - }, - .libcxx => { - const named_frame = tracy.namedFrame("libcxx"); - defer named_frame.end(); - - libcxx.buildLibCXX(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libcxx, - "unable to build libcxx: {s}", - .{@errorName(err)}, - ), - }; - }, - .libcxxabi => { - const named_frame = tracy.namedFrame("libcxxabi"); - defer named_frame.end(); - - libcxx.buildLibCXXABI(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libcxxabi, - "unable to build libcxxabi: {s}", - .{@errorName(err)}, - ), - }; - }, - .libtsan => { - const named_frame = tracy.namedFrame("libtsan"); - defer named_frame.end(); - - libtsan.buildTsan(comp, prog_node) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .libtsan, - "unable to build TSAN library: {s}", - .{@errorName(err)}, - ), - }; - }, - .wasi_libc_crt_file => |crt_file| { - const named_frame = tracy.namedFrame("wasi_libc_crt_file"); - defer named_frame.end(); - - wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| { - // TODO Surface more error details. - comp.lockAndSetMiscFailure( - .wasi_libc_crt_file, - "unable to build WASI libc CRT file: {s}", - .{@errorName(err)}, - ); - }; - }, - .zig_libc => { - const named_frame = tracy.namedFrame("zig_libc"); - defer named_frame.end(); - - comp.buildOutputFromZig( - "c.zig", - .Lib, - &comp.libc_static_lib, - .zig_libc, - prog_node, - ) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.SubCompilationFailed => return, // error reported already - else => comp.lockAndSetMiscFailure( - .zig_libc, - "unable to build zig's multitarget libc: {s}", - .{@errorName(err)}, - ), - }; - }, } } @@ -4761,6 +4655,92 @@ fn buildRt( }; } +fn buildMuslCrtFile(comp: *Compilation, crt_file: musl.CrtFile, prog_node: std.Progress.Node) void { + musl.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.musl_crt_file, "unable to build musl {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildGlibcCrtFile(comp: *Compilation, crt_file: glibc.CrtFile, prog_node: std.Progress.Node) void { + glibc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.glibc_crt_file, "unable to build glibc {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildGlibcSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) void { + glibc.buildSharedObjects(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.glibc_shared_objects, "unable to build glibc shared objects: {s}", .{ + @errorName(err), + }), + }; +} + +fn buildMingwCrtFile(comp: *Compilation, crt_file: mingw.CrtFile, prog_node: std.Progress.Node) void { + mingw.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.mingw_crt_file, "unable to build mingw-w64 {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildWasiLibcCrtFile(comp: *Compilation, crt_file: wasi_libc.CrtFile, prog_node: std.Progress.Node) void { + wasi_libc.buildCrtFile(comp, crt_file, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.wasi_libc_crt_file, "unable to build WASI libc {s}: {s}", .{ + @tagName(crt_file), @errorName(err), + }), + }; +} + +fn buildLibUnwind(comp: *Compilation, prog_node: std.Progress.Node) void { + libunwind.buildStaticLib(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libunwind, "unable to build libunwind: {s}", .{@errorName(err)}), + }; +} + +fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) void { + libcxx.buildLibCxx(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libcxx, "unable to build libcxx: {s}", .{@errorName(err)}), + }; +} + +fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) void { + libcxx.buildLibCxxAbi(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libcxxabi, "unable to build libcxxabi: {s}", .{@errorName(err)}), + }; +} + +fn buildLibTsan(comp: *Compilation, prog_node: std.Progress.Node) void { + libtsan.buildTsan(comp, prog_node) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.libtsan, "unable to build TSAN library: {s}", .{@errorName(err)}), + }; +} + +fn buildZigLibc(comp: *Compilation, prog_node: std.Progress.Node) void { + comp.buildOutputFromZig( + "c.zig", + .Lib, + &comp.libc_static_lib, + .zig_libc, + prog_node, + ) catch |err| switch (err) { + error.SubCompilationFailed => return, // error reported already + else => comp.lockAndSetMiscFailure(.zig_libc, "unable to build zig's multitarget libc: {s}", .{@errorName(err)}), + }; +} + fn reportRetryableCObjectError( comp: *Compilation, c_object: *CObject, @@ -6805,3 +6785,9 @@ pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode { pub fn compilerRtStrip(comp: Compilation) bool { return comp.root_mod.strip; } + +fn testAndClear(b: *bool) bool { + const result = b.*; + b.* = false; + return result; +} diff --git a/src/glibc.zig b/src/glibc.zig index 744e4d1766..83d4439dcd 100644 --- a/src/glibc.zig +++ b/src/glibc.zig @@ -156,29 +156,14 @@ 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, }; -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } @@ -199,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); @@ -381,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 @@ -430,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) { @@ -735,7 +656,9 @@ fn wordDirective(target: std.Target) []const u8 { return if (target.ptrBitWidth() == 64) ".quad" else ".long"; } -pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void { const tracy = trace(@src()); defer tracy.end(); @@ -1362,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/libcxx.zig b/src/libcxx.zig index 6386d493a6..8b9ce044a4 100644 --- a/src/libcxx.zig +++ b/src/libcxx.zig @@ -114,7 +114,7 @@ pub const BuildError = error{ ZigCompilerNotBuiltWithLLVMExtensions, }; -pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { +pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } @@ -357,7 +357,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError! comp.queueLinkTaskMode(crt_file.full_object_path, output_mode); } -pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { +pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } diff --git a/src/mingw.zig b/src/mingw.zig index 1e20d32770..eeed1e6f06 100644 --- a/src/mingw.zig +++ b/src/mingw.zig @@ -17,7 +17,9 @@ pub const CrtFile = enum { mingw32_lib, }; -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } diff --git a/src/musl.zig b/src/musl.zig index 72729982e0..12189df89d 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, @@ -18,7 +16,9 @@ pub const CrtFile = enum { libc_so, }; -pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } @@ -28,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); @@ -327,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/src/wasi_libc.zig b/src/wasi_libc.zig index 34d194a302..a44a187e8f 100644 --- a/src/wasi_libc.zig +++ b/src/wasi_libc.zig @@ -57,7 +57,9 @@ pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []co }; } -pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) !void { +/// TODO replace anyerror with explicit error set, recording user-friendly errors with +/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example. +pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } 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");