@zigc/lib 0.16.0-dev.3013 → 0.16.0-test.0
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.
- package/README.md +1 -5
- package/compiler/build_runner.zig +10 -5
- package/libc/darwin/SDKSettings.json +1 -1
- package/libc/darwin/libSystem.tbd +357 -427
- package/libc/freebsd/lib/csu/aarch64/crt.h +1 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_c.c +33 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_s.S +68 -0
- package/libc/freebsd/lib/csu/amd64/crt.h +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_s.S +86 -0
- package/libc/freebsd/lib/csu/arm/crt.h +1 -0
- package/libc/freebsd/lib/csu/arm/crt1_c.c +79 -0
- package/libc/freebsd/lib/csu/arm/crt1_s.S +77 -0
- package/libc/freebsd/lib/csu/common/crtbegin.c +54 -0
- package/libc/freebsd/lib/csu/common/crtbrand.S +55 -0
- package/libc/freebsd/lib/csu/common/csu_common.h +50 -0
- package/libc/freebsd/lib/csu/common/feature_note.S +47 -0
- package/libc/freebsd/lib/csu/common/ignore_init_note.S +48 -0
- package/libc/freebsd/lib/csu/common/notes.h +32 -0
- package/libc/freebsd/lib/csu/i386/crt.h +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_s.S +91 -0
- package/libc/freebsd/lib/csu/powerpc/crt.h +30 -0
- package/libc/freebsd/lib/csu/powerpc/crt1_c.c +89 -0
- package/libc/freebsd/lib/csu/powerpc/crtsavres.S +189 -0
- package/libc/freebsd/lib/csu/powerpc64/crt.h +30 -0
- package/libc/freebsd/lib/csu/powerpc64/crt1_c.c +83 -0
- package/libc/freebsd/lib/csu/riscv/crt.h +8 -0
- package/libc/freebsd/lib/csu/riscv/crt1_c.c +51 -0
- package/libc/freebsd/lib/csu/riscv/crt1_s.S +51 -0
- package/libc/freebsd/lib/libc/include/libc_private.h +386 -0
- package/libc/include/any-darwin-any/AssertMacros.h +1 -1
- package/libc/include/any-darwin-any/AvailabilityInternal.h +10 -10
- package/libc/include/any-darwin-any/AvailabilityInternalLegacy.h +1 -1
- package/libc/include/any-darwin-any/AvailabilityVersions.h +16 -0
- package/libc/include/any-darwin-any/TargetConditionals.h +5 -21
- package/libc/include/any-darwin-any/_regex.h +11 -3
- package/libc/include/any-darwin-any/copyfile.h +1 -0
- package/libc/include/any-darwin-any/dirent.h +32 -2
- package/libc/include/any-darwin-any/dispatch/base.h +8 -0
- package/libc/include/any-darwin-any/dispatch/dispatch_swift_shims.h +4 -2
- package/libc/include/any-darwin-any/dispatch/once.h +2 -1
- package/libc/include/any-darwin-any/dispatch/workloop.h +2 -0
- package/libc/include/any-darwin-any/glob.h +7 -5
- package/libc/include/any-darwin-any/mach/arm/_structs.h +1 -0
- package/libc/include/any-darwin-any/mach/arm/exception.h +1 -0
- package/libc/include/any-darwin-any/mach/arm/thread_status.h +1 -1
- package/libc/include/any-darwin-any/mach/kern_return.h +4 -0
- package/libc/include/any-darwin-any/mach/mach_host.h +52 -2
- package/libc/include/any-darwin-any/mach/mach_traps.h +5 -1
- package/libc/include/any-darwin-any/mach/mach_types.h +4 -0
- package/libc/include/any-darwin-any/mach/mach_voucher_types.h +9 -0
- package/libc/include/any-darwin-any/mach/machine.h +1 -0
- package/libc/include/any-darwin-any/mach/message.h +21 -0
- package/libc/include/any-darwin-any/mach/port.h +48 -11
- package/libc/include/any-darwin-any/mach/thread_act.h +79 -2
- package/libc/include/any-darwin-any/mach/vm_map.h +54 -2
- package/libc/include/any-darwin-any/mach/vm_prot.h +0 -1
- package/libc/include/any-darwin-any/mach/vm_region.h +8 -0
- package/libc/include/any-darwin-any/mach/vm_statistics.h +39 -12
- package/libc/include/any-darwin-any/mach/vm_types.h +6 -0
- package/libc/include/any-darwin-any/mach-o/loader.h +3 -3
- package/libc/include/any-darwin-any/mach_debug/ipc_info.h +1 -0
- package/libc/include/any-darwin-any/malloc/malloc.h +0 -2
- package/libc/include/any-darwin-any/net/if_var.h +2 -2
- package/libc/include/any-darwin-any/signal.h +5 -2
- package/libc/include/any-darwin-any/simd/math.h +2 -2
- package/libc/include/any-darwin-any/sys/_symbol_aliasing.h +24 -0
- package/libc/include/any-darwin-any/sys/attr.h +5 -1
- package/libc/include/any-darwin-any/sys/fcntl.h +2 -0
- package/libc/include/any-darwin-any/sys/mman.h +3 -4
- package/libc/include/any-darwin-any/sys/paths.h +12 -9
- package/libc/include/any-darwin-any/sys/proc.h +2 -2
- package/libc/include/any-darwin-any/sys/sysctl.h +24 -20
- package/libc/include/any-darwin-any/unistd.h +2 -2
- package/libc/include/any-darwin-any/xpc/activity.h +7 -7
- package/libc/include/any-darwin-any/xpc/connection.h +15 -15
- package/libc/include/any-darwin-any/xpc/listener.h +2 -2
- package/libc/include/any-darwin-any/xpc/peer_requirement.h +13 -13
- package/libc/include/any-darwin-any/xpc/session.h +6 -6
- package/libc/include/any-darwin-any/xpc/xpc.h +14 -14
- package/libc/netbsd/lib/csu/arch/aarch64/crt0.S +45 -0
- package/libc/netbsd/lib/csu/arch/earm/crt0.S +61 -0
- package/libc/netbsd/lib/csu/arch/i386/crt0.S +48 -0
- package/libc/netbsd/lib/csu/arch/m68k/crt0.S +47 -0
- package/libc/netbsd/lib/csu/arch/mips/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/powerpc/crt0.S +56 -0
- package/libc/netbsd/lib/csu/arch/sparc/crt0.S +55 -0
- package/libc/netbsd/lib/csu/arch/sparc64/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/x86_64/crt0.S +48 -0
- package/libc/netbsd/lib/csu/common/crt0-common.c +351 -0
- package/libc/netbsd/lib/csu/common/crtbegin.c +135 -0
- package/libc/netbsd/lib/csu/common/csu-common.h +38 -0
- package/libc/netbsd/lib/csu/common/sysident.S +89 -0
- package/libc/netbsd/lib/csu/common/sysident_assym.h +17 -0
- package/libc/openbsd/lib/csu/aarch64/md_init.h +83 -0
- package/libc/openbsd/lib/csu/amd64/md_init.h +80 -0
- package/libc/openbsd/lib/csu/arm/md_init.h +112 -0
- package/libc/openbsd/lib/csu/crt0.c +76 -0
- package/libc/openbsd/lib/csu/crtbegin.c +61 -0
- package/libc/openbsd/lib/csu/extern.h +54 -0
- package/libc/openbsd/lib/csu/i386/md_init.h +83 -0
- package/libc/openbsd/lib/csu/mips64/md_init.h +127 -0
- package/libc/openbsd/lib/csu/os-note-elf.h +19 -0
- package/libc/openbsd/lib/csu/powerpc/md_init.h +80 -0
- package/libc/openbsd/lib/csu/powerpc64/md_init.h +75 -0
- package/libc/openbsd/lib/csu/riscv64/md_init.h +74 -0
- package/libc/openbsd/lib/csu/sparc64/md_init.h +85 -0
- package/package.json +2 -2
- package/std/Build/Step/Run.zig +4 -4
- package/std/Io/Dir.zig +122 -7
- package/std/Io/File.zig +6 -118
- package/std/Io/Kqueue.zig +1 -0
- package/std/Io/Threaded.zig +50 -46
- package/std/Io/Uring.zig +1 -0
- package/std/Io/net.zig +4 -0
- package/std/Io.zig +3 -3
- package/std/Target.zig +1 -1
- package/std/c.zig +2 -1
- package/std/http/Client.zig +3 -2
- package/std/tar.zig +76 -36
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $ */
|
|
2
|
+
|
|
3
|
+
/*-
|
|
4
|
+
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This code is derived from software contributed to The NetBSD Foundation
|
|
8
|
+
* by Matt Thomas of 3am Software Foundry.
|
|
9
|
+
*
|
|
10
|
+
* Redistribution and use in source and binary forms, with or without
|
|
11
|
+
* modification, are permitted provided that the following conditions
|
|
12
|
+
* are met:
|
|
13
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer.
|
|
15
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
16
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
17
|
+
* documentation and/or other materials provided with the distribution.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
20
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
21
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
22
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
23
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
#include <mips/asm.h>
|
|
33
|
+
|
|
34
|
+
RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:45 joerg Exp $")
|
|
35
|
+
|
|
36
|
+
STRONG_ALIAS(_start,__start)
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* Assumes kernel (or ld_elf.so) passes the following parameters to
|
|
40
|
+
* user-space in registers:
|
|
41
|
+
*
|
|
42
|
+
* a0 stack pointer (0 if setregs didn't fill this in)
|
|
43
|
+
* a1 cleanup
|
|
44
|
+
* a2 Obj_Entry
|
|
45
|
+
* a3 ps_strings
|
|
46
|
+
*
|
|
47
|
+
* XXX Does this violate the ABI?
|
|
48
|
+
* as well as the usual registers (pc, sp, and t9 == pc for ABI).
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
NESTED_NOPROFILE(__start, CALLFRAME_SIZ, ra)
|
|
52
|
+
SETUP_GP
|
|
53
|
+
SETUP_GP64(t3, __start)
|
|
54
|
+
move a0, a1 /* cleanup */
|
|
55
|
+
PTR_L t9,%call16(_C_LABEL(___start))(gp)
|
|
56
|
+
move a1, a3 /* ps_strings */
|
|
57
|
+
.reloc 1f,R_MIPS_JALR,___start
|
|
58
|
+
1: jr t9
|
|
59
|
+
END(__start)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*-
|
|
2
|
+
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This code is derived from software contributed to The NetBSD Foundation
|
|
6
|
+
* by Matt Thomas of 3am Software Foundry.
|
|
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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
18
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
21
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include <powerpc/asm.h>
|
|
31
|
+
|
|
32
|
+
RCSID("$NetBSD: crt0.S,v 1.7 2018/11/26 17:37:45 joerg Exp $")
|
|
33
|
+
|
|
34
|
+
STRONG_ALIAS(_start,__start)
|
|
35
|
+
|
|
36
|
+
.hidden ___start
|
|
37
|
+
|
|
38
|
+
#ifndef _LP64
|
|
39
|
+
.weak _SDA_BASE_
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
ENTRY_NOPROFILE(__start)
|
|
43
|
+
#ifndef _LP64
|
|
44
|
+
bcl 20,31,1f
|
|
45
|
+
1:
|
|
46
|
+
mflr %r11
|
|
47
|
+
/* SVR4 ABI says small data is in r13 */
|
|
48
|
+
addis %r13,%r11,_SDA_BASE_-1b@ha
|
|
49
|
+
addi %r13,%r13,_SDA_BASE_-1b@l
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
mr %r3,%r7 /* cleanup */
|
|
53
|
+
mr %r4,%r8 /* ps_strings */
|
|
54
|
+
|
|
55
|
+
CALL(___start)
|
|
56
|
+
END(__start)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* $NetBSD: crt0.S,v 1.3 2018/11/26 17:37:45 joerg Exp $ */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 1998 Christos Zoulas
|
|
5
|
+
* Copyright (c) 1995 Christopher G. Demetriou
|
|
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
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
17
|
+
* must display the following acknowledgement:
|
|
18
|
+
* This product includes software developed for the
|
|
19
|
+
* NetBSD Project. See http://www.NetBSD.org/ for
|
|
20
|
+
* information about NetBSD.
|
|
21
|
+
* 4. The name of the author may not be used to endorse or promote products
|
|
22
|
+
* derived from this software without specific prior written permission.
|
|
23
|
+
*
|
|
24
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
25
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
26
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
27
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
28
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
29
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
33
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
*
|
|
35
|
+
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#include <machine/asm.h>
|
|
39
|
+
|
|
40
|
+
RCSID("$NetBSD: crt0.S,v 1.3 2018/11/26 17:37:45 joerg Exp $")
|
|
41
|
+
|
|
42
|
+
STRONG_ALIAS(_start,__start)
|
|
43
|
+
|
|
44
|
+
! called with:
|
|
45
|
+
! %g3 = cleanup
|
|
46
|
+
! %g1 = ps_strings
|
|
47
|
+
! call: ___start(cleanup, ps_strings)
|
|
48
|
+
_ENTRY(__start)
|
|
49
|
+
mov 0, %fp
|
|
50
|
+
andn %sp, 7, %sp ! align stack
|
|
51
|
+
sub %sp, 24, %sp ! expand to standard stack frame size
|
|
52
|
+
mov %g3, %o0
|
|
53
|
+
call ___start
|
|
54
|
+
mov %g1, %o1
|
|
55
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* $NetBSD: crt0.S,v 1.2 2018/11/26 17:37:46 joerg Exp $ */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 1998 Christos Zoulas
|
|
5
|
+
* Copyright (c) 1995 Christopher G. Demetriou
|
|
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
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
17
|
+
* must display the following acknowledgement:
|
|
18
|
+
* This product includes software developed for the
|
|
19
|
+
* NetBSD Project. See http://www.NetBSD.org/ for
|
|
20
|
+
* information about NetBSD.
|
|
21
|
+
* 4. The name of the author may not be used to endorse or promote products
|
|
22
|
+
* derived from this software without specific prior written permission.
|
|
23
|
+
*
|
|
24
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
25
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
26
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
27
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
28
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
29
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
33
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
*
|
|
35
|
+
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#include <machine/asm.h>
|
|
39
|
+
|
|
40
|
+
RCSID("$NetBSD: crt0.S,v 1.2 2018/11/26 17:37:46 joerg Exp $")
|
|
41
|
+
|
|
42
|
+
STRONG_ALIAS(_start,__start)
|
|
43
|
+
|
|
44
|
+
.align 4
|
|
45
|
+
.register %g3,#scratch
|
|
46
|
+
.register %g2,#scratch
|
|
47
|
+
|
|
48
|
+
! called with:
|
|
49
|
+
! %g3 = cleanup
|
|
50
|
+
! %g2 = obj
|
|
51
|
+
! %g1 = ps_strings
|
|
52
|
+
! call: ___start(cleanup, ps_strings)
|
|
53
|
+
_ENTRY(__start)
|
|
54
|
+
clr %fp
|
|
55
|
+
clr %g4 ! data base for some memory models
|
|
56
|
+
mov %g3, %o0
|
|
57
|
+
ba,pt %icc,___start
|
|
58
|
+
mov %g1, %o1
|
|
59
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* $NetBSD: crt0.S,v 1.4 2018/11/26 17:37:46 joerg Exp $ */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 1998 Christos Zoulas
|
|
5
|
+
* Copyright (c) 1995 Christopher G. Demetriou
|
|
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
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
17
|
+
* must display the following acknowledgement:
|
|
18
|
+
* This product includes software developed for the
|
|
19
|
+
* NetBSD Project. See http://www.NetBSD.org/ for
|
|
20
|
+
* information about NetBSD.
|
|
21
|
+
* 4. The name of the author may not be used to endorse or promote products
|
|
22
|
+
* derived from this software without specific prior written permission.
|
|
23
|
+
*
|
|
24
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
25
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
26
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
27
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
28
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
29
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
33
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
#include <machine/asm.h>
|
|
37
|
+
|
|
38
|
+
RCSID("$NetBSD: crt0.S,v 1.4 2018/11/26 17:37:46 joerg Exp $")
|
|
39
|
+
|
|
40
|
+
STRONG_ALIAS(_start,__start)
|
|
41
|
+
.hidden ___start
|
|
42
|
+
|
|
43
|
+
_ENTRY(__start)
|
|
44
|
+
andq $~15,%rsp
|
|
45
|
+
subq $8,%rsp
|
|
46
|
+
movq %rdx, %rdi
|
|
47
|
+
movq %rbx, %rsi
|
|
48
|
+
jmp ___start
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/* $NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $ */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 1998 Christos Zoulas
|
|
5
|
+
* Copyright (c) 1995 Christopher G. Demetriou
|
|
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
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
17
|
+
* must display the following acknowledgement:
|
|
18
|
+
* This product includes software developed for the
|
|
19
|
+
* NetBSD Project. See http://www.NetBSD.org/ for
|
|
20
|
+
* information about NetBSD.
|
|
21
|
+
* 4. The name of the author may not be used to endorse or promote products
|
|
22
|
+
* derived from this software without specific prior written permission.
|
|
23
|
+
*
|
|
24
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
25
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
26
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
27
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
28
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
29
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
33
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
*
|
|
35
|
+
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#include <sys/cdefs.h>
|
|
39
|
+
__RCSID("$NetBSD: crt0-common.c,v 1.27 2022/06/21 06:52:17 skrll Exp $");
|
|
40
|
+
|
|
41
|
+
#include <sys/types.h>
|
|
42
|
+
#include <sys/exec.h>
|
|
43
|
+
#include <sys/exec_elf.h>
|
|
44
|
+
#include <sys/syscall.h>
|
|
45
|
+
#include <machine/profile.h>
|
|
46
|
+
#include <stdlib.h>
|
|
47
|
+
#include <unistd.h>
|
|
48
|
+
|
|
49
|
+
#include "csu-common.h"
|
|
50
|
+
|
|
51
|
+
extern int main(int, char **, char **);
|
|
52
|
+
|
|
53
|
+
typedef void (*fptr_t)(void);
|
|
54
|
+
#ifndef HAVE_INITFINI_ARRAY
|
|
55
|
+
extern void _init(void);
|
|
56
|
+
extern void _fini(void);
|
|
57
|
+
#endif
|
|
58
|
+
extern void _libc_init(void);
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
* Arrange for _DYNAMIC to be weak and undefined (and therefore to show up
|
|
62
|
+
* as being at address zero, unless something else defines it). That way,
|
|
63
|
+
* if we happen to be compiling without -static but with without any
|
|
64
|
+
* shared libs present, things will still work.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
|
|
68
|
+
|
|
69
|
+
#ifdef MCRT0
|
|
70
|
+
extern void monstartup(u_long, u_long);
|
|
71
|
+
extern void _mcleanup(void);
|
|
72
|
+
extern unsigned char __etext, __eprol;
|
|
73
|
+
#endif /* MCRT0 */
|
|
74
|
+
|
|
75
|
+
static char empty_string[] = "";
|
|
76
|
+
|
|
77
|
+
char **environ __common;
|
|
78
|
+
struct ps_strings *__ps_strings __common = 0;
|
|
79
|
+
char *__progname __common = empty_string;
|
|
80
|
+
|
|
81
|
+
__dead __dso_hidden void ___start(void (*)(void), struct ps_strings *);
|
|
82
|
+
|
|
83
|
+
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
|
|
84
|
+
|
|
85
|
+
#define _FATAL(str) \
|
|
86
|
+
do { \
|
|
87
|
+
write(2, str, sizeof(str)-1); \
|
|
88
|
+
_exit(1); \
|
|
89
|
+
} while (0)
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* If we are using INIT_ARRAY/FINI_ARRAY and we are linked statically,
|
|
93
|
+
* we have to process these instead of relying on RTLD to do it for us.
|
|
94
|
+
*
|
|
95
|
+
* Since we don't need .init or .fini sections, just code them in C
|
|
96
|
+
* to make life easier.
|
|
97
|
+
*/
|
|
98
|
+
extern const fptr_t __preinit_array_start[] __dso_hidden;
|
|
99
|
+
extern const fptr_t __preinit_array_end[] __dso_hidden __weak;
|
|
100
|
+
extern const fptr_t __init_array_start[] __dso_hidden;
|
|
101
|
+
extern const fptr_t __init_array_end[] __dso_hidden __weak;
|
|
102
|
+
extern const fptr_t __fini_array_start[] __dso_hidden;
|
|
103
|
+
extern const fptr_t __fini_array_end[] __dso_hidden __weak;
|
|
104
|
+
|
|
105
|
+
static inline void
|
|
106
|
+
_preinit(void)
|
|
107
|
+
{
|
|
108
|
+
for (const fptr_t *f = __preinit_array_start; f < __preinit_array_end; f++) {
|
|
109
|
+
(*f)();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static inline void
|
|
114
|
+
_initarray(void)
|
|
115
|
+
{
|
|
116
|
+
for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) {
|
|
117
|
+
(*f)();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static void
|
|
122
|
+
_finiarray(void)
|
|
123
|
+
{
|
|
124
|
+
for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) {
|
|
125
|
+
(*f)();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#if \
|
|
130
|
+
defined(__aarch64__) || \
|
|
131
|
+
defined(__powerpc__) || \
|
|
132
|
+
defined(__sparc__) || \
|
|
133
|
+
defined(__x86_64__)
|
|
134
|
+
#define HAS_IPLTA
|
|
135
|
+
static void fix_iplta(void) __noinline;
|
|
136
|
+
#elif \
|
|
137
|
+
defined(__arm__) || \
|
|
138
|
+
defined(__i386__)
|
|
139
|
+
#define HAS_IPLT
|
|
140
|
+
static void fix_iplt(void) __noinline;
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
#ifdef HAS_IPLTA
|
|
145
|
+
#include <stdio.h>
|
|
146
|
+
extern const Elf_Rela __rela_iplt_start[] __dso_hidden __weak;
|
|
147
|
+
extern const Elf_Rela __rela_iplt_end[] __dso_hidden __weak;
|
|
148
|
+
#ifdef __sparc__
|
|
149
|
+
#define IFUNC_RELOCATION R_TYPE(JMP_IREL)
|
|
150
|
+
#include <machine/elf_support.h>
|
|
151
|
+
#define write_plt(where, value) sparc_write_branch((void *)where, (void *)value)
|
|
152
|
+
#else
|
|
153
|
+
#define IFUNC_RELOCATION R_TYPE(IRELATIVE)
|
|
154
|
+
#define write_plt(where, value) *where = value
|
|
155
|
+
#endif
|
|
156
|
+
|
|
157
|
+
static void
|
|
158
|
+
fix_iplta(void)
|
|
159
|
+
{
|
|
160
|
+
const Elf_Rela *rela, *relalim;
|
|
161
|
+
uintptr_t relocbase = 0;
|
|
162
|
+
Elf_Addr *where, target;
|
|
163
|
+
|
|
164
|
+
rela = __rela_iplt_start;
|
|
165
|
+
relalim = __rela_iplt_end;
|
|
166
|
+
for (; rela < relalim; ++rela) {
|
|
167
|
+
if (ELF_R_TYPE(rela->r_info) != IFUNC_RELOCATION)
|
|
168
|
+
abort();
|
|
169
|
+
where = (Elf_Addr *)(relocbase + rela->r_offset);
|
|
170
|
+
target = (Elf_Addr)(relocbase + rela->r_addend);
|
|
171
|
+
target = ((Elf_Addr(*)(void))target)();
|
|
172
|
+
write_plt(where, target);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
#endif
|
|
176
|
+
#ifdef HAS_IPLT
|
|
177
|
+
extern const Elf_Rel __rel_iplt_start[] __dso_hidden __weak;
|
|
178
|
+
extern const Elf_Rel __rel_iplt_end[] __dso_hidden __weak;
|
|
179
|
+
#define IFUNC_RELOCATION R_TYPE(IRELATIVE)
|
|
180
|
+
|
|
181
|
+
static void
|
|
182
|
+
fix_iplt(void)
|
|
183
|
+
{
|
|
184
|
+
const Elf_Rel *rel, *rellim;
|
|
185
|
+
uintptr_t relocbase = 0;
|
|
186
|
+
Elf_Addr *where, target;
|
|
187
|
+
|
|
188
|
+
rel = __rel_iplt_start;
|
|
189
|
+
rellim = __rel_iplt_end;
|
|
190
|
+
for (; rel < rellim; ++rel) {
|
|
191
|
+
if (ELF_R_TYPE(rel->r_info) != IFUNC_RELOCATION)
|
|
192
|
+
abort();
|
|
193
|
+
where = (Elf_Addr *)(relocbase + rel->r_offset);
|
|
194
|
+
target = ((Elf_Addr(*)(void))*where)();
|
|
195
|
+
*where = target;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
#endif
|
|
199
|
+
|
|
200
|
+
#if defined(__x86_64__) || defined(__i386__)
|
|
201
|
+
# define HAS_RELOCATE_SELF
|
|
202
|
+
# if defined(__x86_64__)
|
|
203
|
+
# define RELA
|
|
204
|
+
# define REL_TAG DT_RELA
|
|
205
|
+
# define RELSZ_TAG DT_RELASZ
|
|
206
|
+
# define REL_TYPE Elf_Rela
|
|
207
|
+
# else
|
|
208
|
+
# define REL_TAG DT_REL
|
|
209
|
+
# define RELSZ_TAG DT_RELSZ
|
|
210
|
+
# define REL_TYPE Elf_Rel
|
|
211
|
+
# endif
|
|
212
|
+
|
|
213
|
+
#include <elf.h>
|
|
214
|
+
|
|
215
|
+
static void relocate_self(struct ps_strings *) __noinline;
|
|
216
|
+
|
|
217
|
+
static void
|
|
218
|
+
relocate_self(struct ps_strings *ps_strings)
|
|
219
|
+
{
|
|
220
|
+
AuxInfo *aux = (AuxInfo *)(ps_strings->ps_argvstr + ps_strings->ps_nargvstr +
|
|
221
|
+
ps_strings->ps_nenvstr + 2);
|
|
222
|
+
uintptr_t relocbase = (uintptr_t)~0U;
|
|
223
|
+
const Elf_Phdr *phdr = NULL;
|
|
224
|
+
Elf_Half phnum = (Elf_Half)~0;
|
|
225
|
+
|
|
226
|
+
for (; aux->a_type != AT_NULL; ++aux) {
|
|
227
|
+
switch (aux->a_type) {
|
|
228
|
+
case AT_BASE:
|
|
229
|
+
if (aux->a_v)
|
|
230
|
+
return;
|
|
231
|
+
break;
|
|
232
|
+
case AT_PHDR:
|
|
233
|
+
phdr = (void *)aux->a_v;
|
|
234
|
+
break;
|
|
235
|
+
case AT_PHNUM:
|
|
236
|
+
phnum = (Elf_Half)aux->a_v;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (phdr == NULL || phnum == (Elf_Half)~0)
|
|
242
|
+
return;
|
|
243
|
+
|
|
244
|
+
const Elf_Phdr *phlimit = phdr + phnum, *dynphdr = NULL;
|
|
245
|
+
|
|
246
|
+
for (; phdr < phlimit; ++phdr) {
|
|
247
|
+
if (phdr->p_type == PT_DYNAMIC)
|
|
248
|
+
dynphdr = phdr;
|
|
249
|
+
if (phdr->p_type == PT_PHDR)
|
|
250
|
+
relocbase = (uintptr_t)phdr - phdr->p_vaddr;
|
|
251
|
+
}
|
|
252
|
+
if (dynphdr == NULL || relocbase == (uintptr_t)~0U)
|
|
253
|
+
return;
|
|
254
|
+
|
|
255
|
+
Elf_Dyn *dynp = (Elf_Dyn *)((uint8_t *)dynphdr->p_vaddr + relocbase);
|
|
256
|
+
|
|
257
|
+
const REL_TYPE *relocs = 0, *relocslim;
|
|
258
|
+
Elf_Addr relocssz = 0;
|
|
259
|
+
|
|
260
|
+
for (; dynp->d_tag != DT_NULL; dynp++) {
|
|
261
|
+
switch (dynp->d_tag) {
|
|
262
|
+
case REL_TAG:
|
|
263
|
+
relocs =
|
|
264
|
+
(const REL_TYPE *)(relocbase + dynp->d_un.d_ptr);
|
|
265
|
+
break;
|
|
266
|
+
case RELSZ_TAG:
|
|
267
|
+
relocssz = dynp->d_un.d_val;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
relocslim = (const REL_TYPE *)((const uint8_t *)relocs + relocssz);
|
|
272
|
+
for (; relocs < relocslim; ++relocs) {
|
|
273
|
+
Elf_Addr *where;
|
|
274
|
+
|
|
275
|
+
where = (Elf_Addr *)(relocbase + relocs->r_offset);
|
|
276
|
+
|
|
277
|
+
switch (ELF_R_TYPE(relocs->r_info)) {
|
|
278
|
+
case R_TYPE(RELATIVE): /* word64 B + A */
|
|
279
|
+
#ifdef RELA
|
|
280
|
+
*where = (Elf_Addr)(relocbase + relocs->r_addend);
|
|
281
|
+
#else
|
|
282
|
+
*where += (Elf_Addr)relocbase;
|
|
283
|
+
#endif
|
|
284
|
+
break;
|
|
285
|
+
#ifdef IFUNC_RELOCATION
|
|
286
|
+
case IFUNC_RELOCATION:
|
|
287
|
+
break;
|
|
288
|
+
#endif
|
|
289
|
+
default:
|
|
290
|
+
abort();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
#endif
|
|
295
|
+
|
|
296
|
+
void
|
|
297
|
+
___start(void (*cleanup)(void), /* from shared loader */
|
|
298
|
+
struct ps_strings *ps_strings)
|
|
299
|
+
{
|
|
300
|
+
#if defined(HAS_RELOCATE_SELF)
|
|
301
|
+
relocate_self(ps_strings);
|
|
302
|
+
#endif
|
|
303
|
+
|
|
304
|
+
if (ps_strings == NULL)
|
|
305
|
+
_FATAL("ps_strings missing\n");
|
|
306
|
+
__ps_strings = ps_strings;
|
|
307
|
+
|
|
308
|
+
environ = ps_strings->ps_envstr;
|
|
309
|
+
|
|
310
|
+
if (ps_strings->ps_argvstr[0] != NULL) {
|
|
311
|
+
char *c;
|
|
312
|
+
__progname = ps_strings->ps_argvstr[0];
|
|
313
|
+
for (c = ps_strings->ps_argvstr[0]; *c; ++c) {
|
|
314
|
+
if (*c == '/')
|
|
315
|
+
__progname = c + 1;
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
__progname = empty_string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (cleanup != NULL)
|
|
322
|
+
atexit(cleanup);
|
|
323
|
+
|
|
324
|
+
_libc_init();
|
|
325
|
+
|
|
326
|
+
if (&rtld_DYNAMIC == NULL) {
|
|
327
|
+
#ifdef HAS_IPLTA
|
|
328
|
+
fix_iplta();
|
|
329
|
+
#endif
|
|
330
|
+
#ifdef HAS_IPLT
|
|
331
|
+
fix_iplt();
|
|
332
|
+
#endif
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
_preinit();
|
|
336
|
+
|
|
337
|
+
#ifdef MCRT0
|
|
338
|
+
atexit(_mcleanup);
|
|
339
|
+
monstartup((u_long)&__eprol, (u_long)&__etext);
|
|
340
|
+
#endif
|
|
341
|
+
|
|
342
|
+
atexit(_finiarray);
|
|
343
|
+
_initarray();
|
|
344
|
+
|
|
345
|
+
#ifndef HAVE_INITFINI_ARRAY
|
|
346
|
+
atexit(_fini);
|
|
347
|
+
_init();
|
|
348
|
+
#endif
|
|
349
|
+
|
|
350
|
+
exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));
|
|
351
|
+
}
|