@zigc/lib 0.15.2-test.1 → 0.15.2-test.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +1 -5
  3. package/libc/freebsd/lib/csu/aarch64/crt.h +1 -0
  4. package/libc/freebsd/lib/csu/aarch64/crt1_c.c +33 -0
  5. package/libc/freebsd/lib/csu/aarch64/crt1_s.S +68 -0
  6. package/libc/freebsd/lib/csu/amd64/crt.h +30 -0
  7. package/libc/freebsd/lib/csu/amd64/crt1_c.c +30 -0
  8. package/libc/freebsd/lib/csu/amd64/crt1_s.S +89 -0
  9. package/libc/freebsd/lib/csu/arm/crt.h +1 -0
  10. package/libc/freebsd/lib/csu/arm/crt1_c.c +80 -0
  11. package/libc/freebsd/lib/csu/arm/crt1_s.S +77 -0
  12. package/libc/freebsd/lib/csu/common/crtbegin.c +95 -0
  13. package/libc/freebsd/lib/csu/common/crtbrand.S +55 -0
  14. package/libc/freebsd/lib/csu/common/crtend.c +65 -0
  15. package/libc/freebsd/lib/csu/common/csu_common.h +50 -0
  16. package/libc/freebsd/lib/csu/common/feature_note.S +47 -0
  17. package/libc/freebsd/lib/csu/common/ignore_init_note.S +48 -0
  18. package/libc/freebsd/lib/csu/common/notes.h +32 -0
  19. package/libc/freebsd/lib/csu/i386/crt.h +30 -0
  20. package/libc/freebsd/lib/csu/i386/crt1_c.c +30 -0
  21. package/libc/freebsd/lib/csu/i386/crt1_s.S +91 -0
  22. package/libc/freebsd/lib/csu/powerpc/crt.h +31 -0
  23. package/libc/freebsd/lib/csu/powerpc/crt1_c.c +89 -0
  24. package/libc/freebsd/lib/csu/powerpc/crtsavres.S +189 -0
  25. package/libc/freebsd/lib/csu/powerpc64/crt.h +31 -0
  26. package/libc/freebsd/lib/csu/powerpc64/crt1_c.c +83 -0
  27. package/libc/freebsd/lib/csu/riscv/crt.h +8 -0
  28. package/libc/freebsd/lib/csu/riscv/crt1_c.c +51 -0
  29. package/libc/freebsd/lib/csu/riscv/crt1_s.S +51 -0
  30. package/libc/freebsd/lib/libc/include/libc_private.h +450 -0
  31. package/libc/netbsd/lib/csu/arch/aarch64/crt0.S +45 -0
  32. package/libc/netbsd/lib/csu/arch/earm/crt0.S +61 -0
  33. package/libc/netbsd/lib/csu/arch/i386/crt0.S +48 -0
  34. package/libc/netbsd/lib/csu/arch/m68k/crt0.S +47 -0
  35. package/libc/netbsd/lib/csu/arch/mips/crt0.S +59 -0
  36. package/libc/netbsd/lib/csu/arch/powerpc/crt0.S +56 -0
  37. package/libc/netbsd/lib/csu/arch/sparc/crt0.S +55 -0
  38. package/libc/netbsd/lib/csu/arch/sparc64/crt0.S +59 -0
  39. package/libc/netbsd/lib/csu/arch/x86_64/crt0.S +48 -0
  40. package/libc/netbsd/lib/csu/common/crt0-common.c +351 -0
  41. package/libc/netbsd/lib/csu/common/crtbegin.c +135 -0
  42. package/libc/netbsd/lib/csu/common/csu-common.h +38 -0
  43. package/libc/netbsd/lib/csu/common/sysident.S +89 -0
  44. package/libc/netbsd/lib/csu/common/sysident_assym.h +17 -0
  45. package/package.json +2 -2
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 Nurul Huda (Apon).
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
package/README.md CHANGED
@@ -27,8 +27,4 @@ The `@zigc/cli` package resolves the correct native binary for your platform via
27
27
  | `@zigc/win32-x64` | Windows x64 |
28
28
  | `@zigc/win32-arm64` | Windows ARM64 |
29
29
 
30
- The standard library is shipped separately in `@zigc/lib` (shared across all platforms).
31
-
32
- ## License
33
-
34
- MIT
30
+ The standard library is shipped separately in `@zigc/lib` (shared across all platforms).
@@ -0,0 +1 @@
1
+ /* Empty so we can include this unconditionally */
@@ -0,0 +1,33 @@
1
+ /* LINTLIBRARY */
2
+ /*-
3
+ * Copyright 1996-1998 John D. Polstra.
4
+ * Copyright 2014 Andrew Turner.
5
+ * Copyright 2014-2015 The FreeBSD Foundation.
6
+ * All rights reserved.
7
+ *
8
+ * Portions of this software were developed by Andrew Turner
9
+ * under sponsorship from the FreeBSD Foundation.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ #include <sys/cdefs.h>
33
+ #include "csu_common.h"
@@ -0,0 +1,68 @@
1
+ /* LINTLIBRARY */
2
+ /*-
3
+ * Copyright 1996-1998 John D. Polstra.
4
+ * Copyright 2014 Andrew Turner.
5
+ * Copyright 2014-2015 The FreeBSD Foundation.
6
+ * All rights reserved.
7
+ *
8
+ * Portions of this software were developed by Andrew Turner
9
+ * under sponsorship from the FreeBSD Foundation.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ #include <machine/asm.h>
33
+ #include <sys/elf_common.h>
34
+
35
+ /*
36
+ * The program entry point
37
+ * void _start(char **ap, void (*cleanup)(void)) __dead2
38
+ */
39
+ ENTRY(_start)
40
+ .cfi_undefined x30
41
+ mov x3, x2 /* cleanup */
42
+ add x1, x0, #8 /* load argv */
43
+ ldr x0, [x0] /* load argc */
44
+ add x2, x1, x0, lsl #3 /* env is after argv */
45
+ add x2, x2, #8 /* argv is null terminated */
46
+ #ifdef PIC
47
+ adrp x4, :got:main
48
+ ldr x4, [x4, :got_lo12:main]
49
+ #else
50
+ ldr x4, =main
51
+ #endif
52
+ #ifdef GCRT
53
+ ldr x5, =eprol
54
+ ldr x6, =etext
55
+ /*
56
+ * __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext)
57
+ */
58
+ bl __libc_start1_gcrt
59
+ eprol:
60
+ #else
61
+ /* __libc_start1(argc, argv, env, cleanup, main) */
62
+ bl __libc_start1
63
+ #endif
64
+ END(_start)
65
+
66
+ .section .note.GNU-stack,"",@progbits
67
+
68
+ GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
@@ -0,0 +1,30 @@
1
+ /*-
2
+ * SPDX-License-Identifier: BSD-1-Clause
3
+ *
4
+ * Copyright 2018 Andrew Turner
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ *
12
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+ */
23
+
24
+ #ifndef _CRT_H_
25
+ #define _CRT_H_
26
+
27
+ /* zig patch: no HAVE_CTORS */
28
+ #define INIT_CALL_SEQ(func) "call " __STRING(func)
29
+
30
+ #endif
@@ -0,0 +1,30 @@
1
+ /* LINTLIBRARY */
2
+ /*-
3
+ * SPDX-License-Identifier: BSD-2-Clause
4
+ *
5
+ * Copyright 1996-1998 John D. Polstra.
6
+ * All rights reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ * 1. Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * 2. Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+
29
+ #include <sys/cdefs.h>
30
+ #include "csu_common.h"
@@ -0,0 +1,89 @@
1
+ /*-
2
+ * SPDX-License-Identifier: BSD-2-Clause
3
+ *
4
+ * Copyright (C) 2023 Dmitry Chagin <dchagin@FreeBSD.org>
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
+ * SUCH DAMAGE.
26
+ */
27
+
28
+ #include <machine/asm.h>
29
+
30
+
31
+ .text
32
+ .align 8
33
+
34
+ /*
35
+ * The program entry point
36
+ * %rdi %rsi
37
+ * void _start(char **ap, void (*cleanup)(void)) __dead2
38
+ */
39
+ .globl _start
40
+ .type _start, @function
41
+ _start:
42
+ .cfi_startproc
43
+ .cfi_undefined %rip /* Terminate call chain. */
44
+ pushq %rbp /* Align stack, terminate call chain. */
45
+ .cfi_def_cfa_offset 8
46
+ movq %rsp, %rbp
47
+ .cfi_offset %rbp, -16
48
+ .cfi_def_cfa_register %rbp
49
+ #ifdef GCRT
50
+ subq $16, %rsp
51
+ #endif
52
+ movq %rsi, %rcx
53
+ movq %rdi, %rsi /* argv = ap */
54
+ addq $8, %rsi /* argv += 1 */
55
+ movq %rdi, %rdx /* env = ap */
56
+ addq $16, %rdx /* env += 2 */
57
+ movslq (%rdi), %rax
58
+ movl %eax, %edi /* argc = *(long *)(void *)ap */
59
+ shlq $3, %rax
60
+ addq %rax, %rdx /* env += argc */
61
+ #ifdef PIC
62
+ /*
63
+ * XXX. %rip relative addressing is not intended for use in the
64
+ * large memory model due to the offset from %rip being limited
65
+ * to 32 bits.
66
+ */
67
+ leaq main@plt(%rip), %r8
68
+ #else
69
+ movabsq $main, %r8
70
+ #endif
71
+ #ifdef GCRT
72
+ movabsq $eprol, %r9
73
+ movabsq $etext, %rax
74
+ movq %rax, (%rsp)
75
+ /*
76
+ * %edi %rsi %rdx %rcx %r8 %r9 (%rsp)
77
+ * __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext)
78
+ */
79
+ callq __libc_start1_gcrt
80
+ eprol:
81
+ #else
82
+ /* __libc_start1(argc, argv, env, cleanup, main) */
83
+ callq __libc_start1
84
+ #endif
85
+ int3
86
+ .cfi_endproc
87
+ .size _start, . - _start
88
+
89
+ .section .note.GNU-stack,"",%progbits
@@ -0,0 +1 @@
1
+ /* Empty so we can include this unconditionally */
@@ -0,0 +1,80 @@
1
+ /* LINTLIBRARY */
2
+ /*-
3
+ * SPDX-License-Identifier: BSD-4-Clause
4
+ *
5
+ * Copyright 2001 David E. O'Brien.
6
+ * All rights reserved.
7
+ * Copyright 1996-1998 John D. Polstra.
8
+ * All rights reserved.
9
+ * Copyright (c) 1997 Jason R. Thorpe.
10
+ * Copyright (c) 1995 Christopher G. Demetriou
11
+ * All rights reserved.
12
+ *
13
+ * Redistribution and use in source and binary forms, with or without
14
+ * modification, are permitted provided that the following conditions
15
+ * are met:
16
+ * 1. Redistributions of source code must retain the above copyright
17
+ * notice, this list of conditions and the following disclaimer.
18
+ * 2. Redistributions in binary form must reproduce the above copyright
19
+ * notice, this list of conditions and the following disclaimer in the
20
+ * documentation and/or other materials provided with the distribution.
21
+ * 3. All advertising materials mentioning features or use of this software
22
+ * must display the following acknowledgement:
23
+ * This product includes software developed for the
24
+ * FreeBSD Project. See https://www.freebsd.org/ for
25
+ * information about FreeBSD.
26
+ * This product includes software developed for the
27
+ * NetBSD Project. See http://www.netbsd.org/ for
28
+ * information about NetBSD.
29
+ * 4. The name of the author may not be used to endorse or promote products
30
+ * derived from this software without specific prior written permission
31
+ *
32
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
+ */
43
+
44
+ #include <sys/cdefs.h>
45
+ #include <sys/param.h>
46
+ #include <sys/elf_common.h>
47
+
48
+ #include "libc_private.h"
49
+ #include "csu_common.h"
50
+
51
+ struct Struct_Obj_Entry;
52
+ struct ps_strings;
53
+
54
+ void _start(int, char **, char **, const struct Struct_Obj_Entry *,
55
+ void (*)(void), struct ps_strings *) __dead2;
56
+
57
+ struct ps_strings *__ps_strings;
58
+
59
+ void __start(int, char **, char **, struct ps_strings *,
60
+ const struct Struct_Obj_Entry *, void (*)(void)) __dead2;
61
+
62
+ void
63
+ __start(int argc, char **argv, char **env, struct ps_strings *ps_strings,
64
+ const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void))
65
+ {
66
+ if (ps_strings != (struct ps_strings *)0)
67
+ __ps_strings = ps_strings;
68
+
69
+ #ifdef GCRT
70
+ __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
71
+ #else
72
+ __libc_start1(argc, argv, env, cleanup, main);
73
+ #endif
74
+ }
75
+
76
+ #ifdef GCRT
77
+ __asm__(".text");
78
+ __asm__("eprol:");
79
+ __asm__(".previous");
80
+ #endif
@@ -0,0 +1,77 @@
1
+ /* LINTLIBRARY */
2
+ /*-
3
+ * SPDX-License-Identifier: BSD-4-Clause
4
+ *
5
+ * Copyright 2001 David E. O'Brien.
6
+ * All rights reserved.
7
+ * Copyright 1996-1998 John D. Polstra.
8
+ * All rights reserved.
9
+ * Copyright (c) 1997 Jason R. Thorpe.
10
+ * Copyright (c) 1995 Christopher G. Demetriou
11
+ * All rights reserved.
12
+ *
13
+ * Redistribution and use in source and binary forms, with or without
14
+ * modification, are permitted provided that the following conditions
15
+ * are met:
16
+ * 1. Redistributions of source code must retain the above copyright
17
+ * notice, this list of conditions and the following disclaimer.
18
+ * 2. Redistributions in binary form must reproduce the above copyright
19
+ * notice, this list of conditions and the following disclaimer in the
20
+ * documentation and/or other materials provided with the distribution.
21
+ * 3. All advertising materials mentioning features or use of this software
22
+ * must display the following acknowledgement:
23
+ * This product includes software developed for the
24
+ * FreeBSD Project. See https://www.freebsd.org/ for
25
+ * information about FreeBSD.
26
+ * This product includes software developed for the
27
+ * NetBSD Project. See http://www.netbsd.org/ for
28
+ * information about NetBSD.
29
+ * 4. The name of the author may not be used to endorse or promote products
30
+ * derived from this software without specific prior written permission
31
+ *
32
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
+ */
43
+
44
+ #include <machine/asm.h>
45
+ #include <sys/param.h>
46
+ #include <sys/elf_common.h>
47
+ #include "notes.h"
48
+
49
+ ENTRY(_start)
50
+ mov r5, r2 /* cleanup */
51
+ mov r4, r1 /* obj_main */
52
+ mov r3, r0 /* ps_strings */
53
+ /* Get argc, argv, and envp from stack */
54
+ ldr r0, [sp, #0x0000]
55
+ add r1, sp, #0x0004
56
+ add r2, r1, r0, lsl #2
57
+ add r2, r2, #0x0004
58
+ /* Ensure the stack is properly aligned before calling C code. */
59
+ bic sp, sp, #7
60
+ sub sp, sp, #8
61
+ str r5, [sp, #4]
62
+ str r4, [sp, #0]
63
+
64
+ b __start
65
+ END(_start)
66
+
67
+ .section .note.tag,"a",%note
68
+ .p2align 2
69
+ .4byte 2f-1f
70
+ .4byte 4f-3f
71
+ .4byte NT_FREEBSD_ARCH_TAG
72
+ 1: .asciz NOTE_FREEBSD_VENDOR
73
+ 2: .p2align 2
74
+ 3: .asciz MACHINE_ARCH
75
+ 4:
76
+
77
+ .section .note.GNU-stack,"",%progbits
@@ -0,0 +1,95 @@
1
+ /*-
2
+ * SPDX-License-Identifier: BSD-1-Clause
3
+ *
4
+ * Copyright 2018 Andrew Turner
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ *
12
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+ */
23
+
24
+ #include <sys/cdefs.h>
25
+ #include <sys/param.h>
26
+
27
+ #include "crt.h"
28
+
29
+ typedef void (*crt_func)(void);
30
+
31
+ extern void *__dso_handle __hidden;
32
+
33
+ #ifndef SHARED
34
+ void *__dso_handle = 0;
35
+ #else
36
+ void *__dso_handle = &__dso_handle;
37
+ void __cxa_finalize(void *) __weak_symbol;
38
+
39
+ /*
40
+ * Call __cxa_finalize with the dso handle in shared objects.
41
+ * When we have ctors/dtors call from the dtor handler before calling
42
+ * any dtors, otherwise use a destructor.
43
+ */
44
+ #ifndef HAVE_CTORS
45
+ __attribute__((destructor))
46
+ #endif
47
+ static void
48
+ run_cxa_finalize(void)
49
+ {
50
+
51
+ if (__cxa_finalize != NULL)
52
+ __cxa_finalize(__dso_handle);
53
+ }
54
+ #endif
55
+
56
+ /*
57
+ * On some architectures and toolchains we may need to call the .dtors.
58
+ * These are called in the order they are in the ELF file.
59
+ */
60
+ #ifdef HAVE_CTORS
61
+ static void __do_global_dtors_aux(void) __used;
62
+
63
+ static crt_func __CTOR_LIST__[] __section(".ctors") __used = {
64
+ (crt_func)-1
65
+ };
66
+ static crt_func __DTOR_LIST__[] __section(".dtors") __used = {
67
+ (crt_func)-1
68
+ };
69
+
70
+ static void
71
+ __do_global_dtors_aux(void)
72
+ {
73
+ crt_func fn;
74
+ int n;
75
+
76
+ #ifdef SHARED
77
+ run_cxa_finalize();
78
+ #endif
79
+
80
+ for (n = 1;; n++) {
81
+ fn = __DTOR_LIST__[n];
82
+ if (fn == (crt_func)0 || fn == (crt_func)-1)
83
+ break;
84
+ fn();
85
+ }
86
+ }
87
+
88
+ asm (
89
+ ".pushsection .fini \n"
90
+ "\t" INIT_CALL_SEQ(__do_global_dtors_aux) "\n"
91
+ ".popsection \n"
92
+ );
93
+ #endif
94
+
95
+ /* zig patch: remove gcj nonsense */
@@ -0,0 +1,55 @@
1
+ /*-
2
+ * SPDX-License-Identifier: BSD-2-Clause
3
+ *
4
+ * Copyright 2000 David E. O'Brien, John D. Polstra.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions
9
+ * are met:
10
+ * 1. Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ #include <machine/asm.h>
29
+ #include <sys/param.h>
30
+ #include <sys/elf_common.h>
31
+ #include "notes.h"
32
+
33
+ /*
34
+ * Special ".note.tag" entry specifying the ABI version. See
35
+ * http://www.netbsd.org/Documentation/kernel/elf-notes.html
36
+ * for more information.
37
+ */
38
+
39
+ .section .note.tag,"aG",%note,.freebsd.noteG,comdat
40
+ .p2align 2
41
+ .4byte 2f-1f
42
+ .4byte 4f-3f
43
+ .4byte NT_FREEBSD_ABI_TAG
44
+ 1: .asciz NOTE_FREEBSD_VENDOR
45
+ 2: .p2align 2
46
+ /* zig patch: use __FreeBSD_version which is defined by the compiler */
47
+ 3: .4byte __FreeBSD_version
48
+ 4:
49
+
50
+ .section .note.GNU-stack,"",%progbits
51
+
52
+ #ifdef __aarch64__
53
+ /* This is needed in all objects for BTI to be used in the linked elf file */
54
+ GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
55
+ #endif
@@ -0,0 +1,65 @@
1
+ /*-
2
+ * SPDX-License-Identifier: BSD-1-Clause
3
+ *
4
+ * Copyright 2018 Andrew Turner
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ *
12
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+ */
23
+
24
+ #include <sys/cdefs.h>
25
+ #include "crt.h"
26
+
27
+ typedef void (*crt_func)(void);
28
+
29
+ /* zig patch: remove gcj nonsense */
30
+
31
+ #ifdef HAVE_CTORS
32
+
33
+ /*
34
+ * On some architectures and toolchains we may need to call the .ctors.
35
+ * These are called in the reverse order they are in the ELF file.
36
+ */
37
+ static void __do_global_ctors_aux(void) __used;
38
+
39
+ static crt_func __CTOR_END__[] __section(".ctors") __used = {
40
+ (crt_func)0
41
+ };
42
+ static crt_func __DTOR_END__[] __section(".dtors") __used = {
43
+ (crt_func)0
44
+ };
45
+
46
+ static void
47
+ __do_global_ctors_aux(void)
48
+ {
49
+ crt_func fn;
50
+ int n;
51
+
52
+ for (n = 1;; n++) {
53
+ fn = __CTOR_END__[-n];
54
+ if (fn == (crt_func)0 || fn == (crt_func)-1)
55
+ break;
56
+ fn();
57
+ }
58
+ }
59
+
60
+ asm (
61
+ ".pushsection .init \n"
62
+ "\t" INIT_CALL_SEQ(__do_global_ctors_aux) "\n"
63
+ ".popsection \n"
64
+ );
65
+ #endif