authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-22 08:04:16+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-10 12:19:26+02:00
loga36dcef7dc513b2d63c1666c172b527a93f90fac
tree1af5a9853ebcd11ed108c52958a0a03ce3a3353f
parent01390cc533b471c5a8ad13b8b1380a508b630fef
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libc: Add FreeBSD libc startup code from 14.2.0.

* NT_FREEBSD_ABI_TAG was manually adjusted from using a hardcoded value to using __FreeBSD_version which will be defined by the compiler. * GCJ stuff was removed. * HAVE_CTORS definitions were removed.

29 files changed, 2060 insertions(+), 0 deletions(-)

lib/libc/freebsd/COPYRIGHT created+125
...@@ -0,0 +1,125 @@
1# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
2
3The compilation of software known as FreeBSD is distributed under the
4following terms:
5
6Copyright (c) 1992-2023 The FreeBSD Project.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions
10are met:
111. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
132. 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
17THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27SUCH DAMAGE.
28
29The 4.4BSD and 4.4BSD-Lite software is distributed under the following
30terms:
31
32All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
33Releases is copyrighted by The Regents of the University of California.
34
35Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
36 The Regents of the University of California. All rights reserved.
37
38Redistribution and use in source and binary forms, with or without
39modification, are permitted provided that the following conditions
40are met:
411. Redistributions of source code must retain the above copyright
42 notice, this list of conditions and the following disclaimer.
432. Redistributions in binary form must reproduce the above copyright
44 notice, this list of conditions and the following disclaimer in the
45 documentation and/or other materials provided with the distribution.
463. All advertising materials mentioning features or use of this software
47 must display the following acknowledgement:
48This product includes software developed by the University of
49California, Berkeley and its contributors.
504. Neither the name of the University nor the names of its contributors
51 may be used to endorse or promote products derived from this software
52 without specific prior written permission.
53
54THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64SUCH DAMAGE.
65
66The Institute of Electrical and Electronics Engineers and the American
67National Standards Committee X3, on Information Processing Systems have
68given us permission to reprint portions of their documentation.
69
70In the following statement, the phrase ``this text'' refers to portions
71of the system documentation.
72
73Portions of this text are reprinted and reproduced in electronic form in
74the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE
75Standard Portable Operating System Interface for Computer Environments
76(POSIX), copyright C 1988 by the Institute of Electrical and Electronics
77Engineers, Inc. In the event of any discrepancy between these versions
78and the original IEEE Standard, the original IEEE Standard is the referee
79document.
80
81In the following statement, the phrase ``This material'' refers to portions
82of the system documentation.
83
84This material is reproduced with permission from American National
85Standards Committee X3, on Information Processing Systems. Computer and
86Business Equipment Manufacturers Association (CBEMA), 311 First St., NW,
87Suite 500, Washington, DC 20001-2178. The developmental work of
88Programming Language C was completed by the X3J11 Technical Committee.
89
90The views and conclusions contained in the software and documentation are
91those of the authors and should not be interpreted as representing official
92policies, either expressed or implied, of the Regents of the University
93of California.
94
95
96NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD")
97source has been updated. The copyright addendum may be found at
98ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is
99included below.
100
101July 22, 1999
102
103To All Licensees, Distributors of Any Version of BSD:
104
105As you know, certain of the Berkeley Software Distribution ("BSD") source
106code files require that further distributions of products containing all or
107portions of the software, acknowledge within their advertising materials
108that such products contain software developed by UC Berkeley and its
109contributors.
110
111Specifically, the provision reads:
112
113" * 3. All advertising materials mentioning features or use of this software
114 * must display the following acknowledgement:
115 * This product includes software developed by the University of
116 * California, Berkeley and its contributors."
117
118Effective immediately, licensees and distributors are no longer required to
119include the acknowledgement within advertising materials. Accordingly, the
120foregoing paragraph of those BSD Unix files containing it is hereby deleted
121in its entirety.
122
123William Hoskins
124Director, Office of Technology Licensing
125University of California, Berkeley
lib/libc/freebsd/lib/csu/aarch64/crt.h created+1
...@@ -0,0 +1 @@
1/* Empty so we can include this unconditionally */
lib/libc/freebsd/lib/csu/aarch64/crt1_c.c created+33
...@@ -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"
lib/libc/freebsd/lib/csu/aarch64/crt1_s.S created+68
...@@ -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 */
39ENTRY(_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
59eprol:
60#else
61 /* __libc_start1(argc, argv, env, cleanup, main) */
62 bl __libc_start1
63#endif
64END(_start)
65
66 .section .note.GNU-stack,"",@progbits
67
68GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
lib/libc/freebsd/lib/csu/amd64/crt.h created+30
...@@ -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
lib/libc/freebsd/lib/csu/amd64/crt1_c.c created+30
...@@ -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"
lib/libc/freebsd/lib/csu/amd64/crt1_s.S created+89
...@@ -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
80eprol:
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
lib/libc/freebsd/lib/csu/arm/crt.h created+1
...@@ -0,0 +1 @@
1/* Empty so we can include this unconditionally */
lib/libc/freebsd/lib/csu/arm/crt1_c.c created+80
...@@ -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
51struct Struct_Obj_Entry;
52struct ps_strings;
53
54void _start(int, char **, char **, const struct Struct_Obj_Entry *,
55 void (*)(void), struct ps_strings *) __dead2;
56
57struct ps_strings *__ps_strings;
58
59void __start(int, char **, char **, struct ps_strings *,
60 const struct Struct_Obj_Entry *, void (*)(void)) __dead2;
61
62void
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
lib/libc/freebsd/lib/csu/arm/crt1_s.S created+77
...@@ -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
49ENTRY(_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
65END(_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
721: .asciz NOTE_FREEBSD_VENDOR
732: .p2align 2
743: .asciz MACHINE_ARCH
754:
76
77 .section .note.GNU-stack,"",%progbits
lib/libc/freebsd/lib/csu/common/crtbegin.c created+95
...@@ -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
29typedef void (*crt_func)(void);
30
31extern void *__dso_handle __hidden;
32
33#ifndef SHARED
34void *__dso_handle = 0;
35#else
36void *__dso_handle = &__dso_handle;
37void __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
47static void
48run_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
61static void __do_global_dtors_aux(void) __used;
62
63static crt_func __CTOR_LIST__[] __section(".ctors") __used = {
64 (crt_func)-1
65};
66static crt_func __DTOR_LIST__[] __section(".dtors") __used = {
67 (crt_func)-1
68};
69
70static 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
88asm (
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 */
lib/libc/freebsd/lib/csu/common/crtbrand.S created+55
...@@ -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
441: .asciz NOTE_FREEBSD_VENDOR
452: .p2align 2
46/* zig patch: use __FreeBSD_version which is defined by the compiler */
473: .4byte __FreeBSD_version
484:
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 */
54GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
55#endif
lib/libc/freebsd/lib/csu/common/crtend.c created+65
...@@ -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
27typedef 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 */
37static void __do_global_ctors_aux(void) __used;
38
39static crt_func __CTOR_END__[] __section(".ctors") __used = {
40 (crt_func)0
41};
42static crt_func __DTOR_END__[] __section(".dtors") __used = {
43 (crt_func)0
44};
45
46static 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
60asm (
61 ".pushsection .init \n"
62 "\t" INIT_CALL_SEQ(__do_global_ctors_aux) "\n"
63 ".popsection \n"
64);
65#endif
lib/libc/freebsd/lib/csu/common/csu_common.h created+50
...@@ -0,0 +1,50 @@
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright 1996-1998 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#ifdef _CSU_COMMON_H_
29
30/*
31 * This file includes both definitions and declarations, it can be
32 * included only into one compilation unit for csu objects. We cannot
33 * practically check this, but at least guard against
34 * double-inclusion.
35 */
36#error "Include this file only once"
37#else
38#define _CSU_COMMON_H_
39
40char **environ;
41const char *__progname = "";
42
43#ifdef GCRT
44extern int eprol;
45extern int etext;
46#endif
47
48int main(int, char **, char **);
49
50#endif /* _CSU_COMMON_H_ */
lib/libc/freebsd/lib/csu/common/feature_note.S created+47
...@@ -0,0 +1,47 @@
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/elf_common.h>
30#include "notes.h"
31
32 .section .note.tag,"a",%note
33 .p2align 2
34 .4byte 2f-1f
35 .4byte 4f-3f
36 .4byte NT_FREEBSD_FEATURE_CTL
371: .asciz NOTE_FREEBSD_VENDOR
382: .p2align 2
393: .4byte 0
404:
41
42 .section .note.GNU-stack,"",%progbits
43
44#ifdef __aarch64__
45/* This is needed in all objects for BTI to be used in the linked elf file */
46GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
47#endif
lib/libc/freebsd/lib/csu/common/ignore_init_note.S created+48
...@@ -0,0 +1,48 @@
1/*-
2 * SPDX-License-Identifier: BSD-1-Clause
3 *
4 * Copyright 2012 Konstantin Belousov <kib@FreeBSD.org>
5 * Copyright (c) 2018 The FreeBSD Foundation
6 *
7 * Parts of this software was developed by Konstantin Belousov
8 * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
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 *
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/elf_common.h>
30
31#include "notes.h"
32
33 .section .note.tag,"a",%note
34 .p2align 2
35 .4byte 2f-1f
36 .4byte 4f-3f
37 .4byte NT_FREEBSD_NOINIT_TAG
381: .asciz NOTE_FREEBSD_VENDOR
392: .p2align 2
403: .4byte 0
414:
42
43 .section .note.GNU-stack,"",%progbits
44
45#ifdef __aarch64__
46/* This is needed in all objects for BTI to be used in the linked elf file */
47GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
48#endif
lib/libc/freebsd/lib/csu/common/notes.h created+32
...@@ -0,0 +1,32 @@
1/*-
2 * SPDX-License-Identifier: BSD-1-Clause
3 *
4 * Copyright 2012 Konstantin Belousov <kib@FreeBSD.org>
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 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#ifndef CSU_COMMON_NOTES_H
26#define CSU_COMMON_NOTES_H
27
28#define NOTE_FREEBSD_VENDOR "FreeBSD"
29
30#define NOTE_SECTION ".note.tag"
31
32#endif
lib/libc/freebsd/lib/csu/i386/crt.h created+30
...@@ -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
lib/libc/freebsd/lib/csu/i386/crt1_c.c created+30
...@@ -0,0 +1,30 @@
1/* LINTLIBRARY */
2/*-
3 * Copyright 1996-1998 John D. Polstra.
4 * All rights reserved.
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 ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28#include "csu_common.h"
29
30void _start(char *, ...) __dead2;
lib/libc/freebsd/lib/csu/i386/crt1_s.S created+91
...@@ -0,0 +1,91 @@
1/*-
2 * Copyright 2009 Konstantin Belousov.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
13 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
17 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
18 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 */
22
23#include <machine/asm.h>
24 .text
25 .align 4
26 .globl _start
27 .type _start, @function
28_start:
29 .cfi_startproc
30 .cfi_undefined %eip
31 popl %esi # Pop argc
32 .cfi_def_cfa_offset -4
33 movl %esp,%edi # argv starts at stack top
34 xorl %ebp,%ebp
35 pushl %ebp
36 .cfi_def_cfa_offset 0
37 movl %esp,%ebp
38 .cfi_offset %ebp,-4
39 .cfi_def_cfa_register %ebp
40 andl $0xfffffff0,%esp # align stack
41
42#ifdef GCRT
43 subl $4,%esp # Align stack for 7 arguments
44 pushl $etext
45 pushl $eprol
46eprol:
47#else
48 subl $12,%esp # Align stack for 5 arguments
49#endif /* GCRT */
50
51#ifdef PIC
52 calll 1f
531: popl %ebx
54 addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
55 leal main@GOTOFF(%ebx),%eax
56 pushl %eax
57#else
58 pushl $main
59#endif /* PIC */
60
61 pushl %edx # rtld cleanup
62 /* env = argv + argc + 1 */
63 movl %edi,%eax # env = argv
64 movl %esi,%ecx
65 shll $2,%ecx # argc * 4
66 addl %ecx,%eax # env += argc
67 addl $4,%eax # env += 1
68 pushl %eax # env
69 pushl %edi # argv
70 pushl %esi # argc
71
72#ifdef GCRT
73 /*
74 * __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
75 */
76 calll __libc_start1_gcrt
77#else
78 /*
79 * __libc_start1(argc, argv, env, cleanup, main);
80 */
81#ifdef PIC
82 calll __libc_start1@PLT
83#else
84 calll __libc_start1
85#endif
86#endif /* GCRT */
87 int3
88 .cfi_endproc
89 .size _start, . - _start
90
91 .section .note.GNU-stack,"",%progbits
lib/libc/freebsd/lib/csu/powerpc/crt.h created+31
...@@ -0,0 +1,31 @@
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 CTORS_CONSTRUCTORS
29#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
30
31#endif
lib/libc/freebsd/lib/csu/powerpc/crt1_c.c created+89
...@@ -0,0 +1,89 @@
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 <stdlib.h>
46
47#include "libc_private.h"
48#include "csu_common.h"
49
50struct Struct_Obj_Entry;
51struct ps_strings;
52
53struct ps_strings *__ps_strings;
54
55void _start(int, char **, char **, const struct Struct_Obj_Entry *,
56 void (*)(void), struct ps_strings *) __dead2;
57
58/* The entry function. */
59/*
60 * First 5 arguments are specified by the PowerPC SVR4 ABI.
61 * The last argument, ps_strings, is a BSD extension.
62 */
63/* ARGSUSED */
64void
65_start(int argc, char **argv, char **env,
66 const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void),
67 struct ps_strings *ps_strings)
68{
69 if (ps_strings != (struct ps_strings *)0)
70 __ps_strings = ps_strings;
71
72#ifdef GCRT
73 __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
74#else
75 __libc_start1(argc, argv, env, cleanup, main);
76#endif
77}
78
79#ifdef GCRT
80__asm__(".text");
81__asm__("eprol:");
82__asm__(".previous");
83#endif
84
85#ifndef PIC
86__asm__(".text\n"
87 "\t.global _GLOBAL_OFFSET_TABLE_\n"
88 "\t.reloc 0, R_PPC_NONE, _GLOBAL_OFFSET_TABLE_");
89#endif
lib/libc/freebsd/lib/csu/powerpc/crtsavres.S created+189
...@@ -0,0 +1,189 @@
1/*-
2 * SPDX-License-Identifier: BSD-1-Clause
3 *
4 * Copyright 2019 Justin Hibbits
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 <machine/asm.h>
25.text
26
27/*
28 * The PowerPC ABI spec requires the following save/restore functions to be
29 * provided:
30 *
31 * _savefpr_N
32 * _restfpr_N
33 * _restfpr_N_x
34 * _savegpr_N
35 * _restgpr_N
36 * _restgpr_N_x
37 *
38 * With N ranging from 14 to 31, to save the nonvolatile registers.
39 */
40
41#define _CRTENTRY(name) \
42 .text; \
43 .globl name; \
44 .type name,@function; \
45 name:
46
47#define SAVEFPR(r) _CRTENTRY(__CONCAT(_savefpr_,r)) \
48 stfd r,(-256 + r * 8)(11)
49
50SAVEFPR(14)
51SAVEFPR(15)
52SAVEFPR(16)
53SAVEFPR(17)
54SAVEFPR(18)
55SAVEFPR(19)
56SAVEFPR(20)
57SAVEFPR(21)
58SAVEFPR(22)
59SAVEFPR(23)
60SAVEFPR(24)
61SAVEFPR(25)
62SAVEFPR(26)
63SAVEFPR(27)
64SAVEFPR(28)
65SAVEFPR(29)
66SAVEFPR(30)
67SAVEFPR(31)
68 blr
69
70#define RESTFPR(r) _CRTENTRY(__CONCAT(_restfpr_,r)) \
71 lfd r,(-256 + r * 8)(11)
72
73RESTFPR(14)
74RESTFPR(15)
75RESTFPR(16)
76RESTFPR(17)
77RESTFPR(18)
78RESTFPR(19)
79RESTFPR(20)
80RESTFPR(21)
81RESTFPR(22)
82RESTFPR(23)
83RESTFPR(24)
84RESTFPR(25)
85RESTFPR(26)
86RESTFPR(27)
87RESTFPR(28)
88RESTFPR(29)
89RESTFPR(30)
90RESTFPR(31)
91 blr
92
93#define SAVEGPR(r) _CRTENTRY(__CONCAT(_savegpr_,r)) \
94 stw r,(-128 + r * 4)(11)
95
96SAVEGPR(14)
97SAVEGPR(15)
98SAVEGPR(16)
99SAVEGPR(17)
100SAVEGPR(18)
101SAVEGPR(19)
102SAVEGPR(20)
103SAVEGPR(21)
104SAVEGPR(22)
105SAVEGPR(23)
106SAVEGPR(24)
107SAVEGPR(25)
108SAVEGPR(26)
109SAVEGPR(27)
110SAVEGPR(28)
111SAVEGPR(29)
112SAVEGPR(30)
113SAVEGPR(31)
114 blr
115
116#define RESTGPR(r) _CRTENTRY(__CONCAT(_restgpr_,r)) \
117 lwz r,(-128 + r*4)(11)
118
119RESTGPR(14)
120RESTGPR(15)
121RESTGPR(16)
122RESTGPR(17)
123RESTGPR(18)
124RESTGPR(19)
125RESTGPR(20)
126RESTGPR(21)
127RESTGPR(22)
128RESTGPR(23)
129RESTGPR(24)
130RESTGPR(25)
131RESTGPR(26)
132RESTGPR(27)
133RESTGPR(28)
134RESTGPR(29)
135RESTGPR(30)
136RESTGPR(31)
137 blr
138
139#define RESTFPR_X(r) _CRTENTRY(__CONCAT(__CONCAT(_restfpr_,r),_x)) \
140 lfd r,(-256 + r * 8)(11)
141
142RESTFPR_X(14)
143RESTFPR_X(15)
144RESTFPR_X(16)
145RESTFPR_X(17)
146RESTFPR_X(18)
147RESTFPR_X(19)
148RESTFPR_X(20)
149RESTFPR_X(21)
150RESTFPR_X(22)
151RESTFPR_X(23)
152RESTFPR_X(24)
153RESTFPR_X(25)
154RESTFPR_X(26)
155RESTFPR_X(27)
156RESTFPR_X(28)
157RESTFPR_X(29)
158RESTFPR_X(30)
159RESTFPR_X(31)
160 lwz 0,4(11)
161 mtlr 0
162 mr 1,11
163 blr
164
165#define RESTGPR_X(r) _CRTENTRY(__CONCAT(__CONCAT(_restgpr_,r),_x)) \
166 lwz r,(-128 + r * 4)(11)
167
168RESTGPR_X(14)
169RESTGPR_X(15)
170RESTGPR_X(16)
171RESTGPR_X(17)
172RESTGPR_X(18)
173RESTGPR_X(19)
174RESTGPR_X(20)
175RESTGPR_X(21)
176RESTGPR_X(22)
177RESTGPR_X(23)
178RESTGPR_X(24)
179RESTGPR_X(25)
180RESTGPR_X(26)
181RESTGPR_X(27)
182RESTGPR_X(28)
183RESTGPR_X(29)
184RESTGPR_X(30)
185RESTGPR_X(31)
186 lwz 0,4(11)
187 mtlr 0
188 mr 1,11
189 blr
lib/libc/freebsd/lib/csu/powerpc64/crt.h created+31
...@@ -0,0 +1,31 @@
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 CTORS_CONSTRUCTORS
29#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
30
31#endif
lib/libc/freebsd/lib/csu/powerpc64/crt1_c.c created+83
...@@ -0,0 +1,83 @@
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 <stdint.h>
46#include <sys/elf.h>
47
48#include "libc_private.h"
49#include "csu_common.h"
50
51struct Struct_Obj_Entry;
52struct ps_strings;
53
54void _start(int, char **, char **, const struct Struct_Obj_Entry *,
55 void (*)(void), struct ps_strings *) __dead2;
56
57struct ps_strings *__ps_strings;
58
59/* The entry function. */
60/*
61 * First 5 arguments are specified by the PowerPC SVR4 ABI.
62 * The last argument, ps_strings, is a BSD extension.
63 */
64void
65_start(int argc, char **argv, char **env,
66 const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void),
67 struct ps_strings *ps_strings)
68{
69 if (ps_strings != (struct ps_strings *)0)
70 __ps_strings = ps_strings;
71
72#ifdef GCRT
73 __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
74#else
75 __libc_start1(argc, argv, env, cleanup, main);
76#endif
77}
78
79#ifdef GCRT
80__asm__(".text");
81__asm__("eprol:");
82__asm__(".previous");
83#endif
lib/libc/freebsd/lib/csu/riscv/crt.h created+8
...@@ -0,0 +1,8 @@
1
2#ifndef _CRT_H_
3#define _CRT_H_
4
5/* zig patch: no HAVE_CTORS */
6#define INIT_CALL_SEQ(func) "call " __STRING(func)
7
8#endif
lib/libc/freebsd/lib/csu/riscv/crt1_c.c created+51
...@@ -0,0 +1,51 @@
1/* LINTLIBRARY */
2/*-
3 * Copyright 1996-1998 John D. Polstra.
4 * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
5 * All rights reserved.
6 *
7 * Portions of this software were developed by SRI International and the
8 * University of Cambridge Computer Laboratory under DARPA/AFRL contract
9 * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
10 *
11 * Portions of this software were developed by the University of Cambridge
12 * Computer Laboratory as part of the CTSRD Project, with support from the
13 * UK Higher Education Innovation Fund (HEIF).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
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 <sys/cdefs.h>
37#include "libc_private.h"
38#include "csu_common.h"
39
40void __start(int argc, char **argv, char **env, void (*cleanup)(void)) __dead2;
41
42void
43__start(int argc, char **argv, char **env, void (*cleanup)(void))
44{
45#ifdef GCRT
46 __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
47__asm__("eprol:");
48#else
49 __libc_start1(argc, argv, env, cleanup, main);
50#endif
51}
lib/libc/freebsd/lib/csu/riscv/crt1_s.S created+51
...@@ -0,0 +1,51 @@
1/* LINTLIBRARY */
2/*-
3 * Copyright 1996-1998 John D. Polstra.
4 * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
5 * All rights reserved.
6 *
7 * Portions of this software were developed by SRI International and the
8 * University of Cambridge Computer Laboratory under DARPA/AFRL contract
9 * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
10 *
11 * Portions of this software were developed by the University of Cambridge
12 * Computer Laboratory as part of the CTSRD Project, with support from the
13 * UK Higher Education Innovation Fund (HEIF).
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
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>
37ENTRY(_start)
38 mv a3, a2 # cleanup
39 addi a1, a0, 8 # get argv
40 ld a0, 0(a0) # load argc
41 slli t0, a0, 3 # mult by arg size
42 add a2, a1, t0 # env is after argv
43 addi a2, a2, 8 # argv is null terminated
44 .option push
45 .option norelax
46 lla gp, __global_pointer$
47 .option pop
48 call __start
49END(_start)
50
51 .section .note.GNU-stack,"",%progbits
lib/libc/freebsd/lib/libc/include/libc_private.h created+450
...@@ -0,0 +1,450 @@
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
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 * 3. Neither the name of the author nor the names of any co-contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * Private definitions for libc, libc_r and libpthread.
32 *
33 */
34
35#ifndef _LIBC_PRIVATE_H_
36#define _LIBC_PRIVATE_H_
37#include <sys/_types.h>
38#include <sys/_pthreadtypes.h>
39
40extern char **environ;
41
42/*
43 * The kernel doesn't expose PID_MAX to the user space. Save it here
44 * to allow to run a newer world on a pre-1400079 kernel.
45 */
46#define _PID_MAX 99999
47
48/*
49 * This global flag is non-zero when a process has created one
50 * or more threads. It is used to avoid calling locking functions
51 * when they are not required.
52 */
53#ifndef __LIBC_ISTHREADED_DECLARED
54#define __LIBC_ISTHREADED_DECLARED
55extern int __isthreaded;
56#endif
57
58/*
59 * Elf_Auxinfo *__elf_aux_vector, the pointer to the ELF aux vector
60 * provided by kernel. Either set for us by rtld, or found at runtime
61 * on stack for static binaries.
62 *
63 * Type is void to avoid polluting whole libc with ELF types.
64 */
65extern void *__elf_aux_vector;
66
67/*
68 * libc should use libc_dlopen internally, which respects a global
69 * flag where loading of new shared objects can be restricted.
70 */
71void *libc_dlopen(const char *, int);
72
73/*
74 * For dynamic linker.
75 */
76void _rtld_error(const char *fmt, ...);
77
78/*
79 * File lock contention is difficult to diagnose without knowing
80 * where locks were set. Allow a debug library to be built which
81 * records the source file and line number of each lock call.
82 */
83#ifdef _FLOCK_DEBUG
84#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__)
85#else
86#define _FLOCKFILE(x) _flockfile(x)
87#endif
88
89/*
90 * Macros for locking and unlocking FILEs. These test if the
91 * process is threaded to avoid locking when not required.
92 */
93#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
94#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
95
96struct _spinlock;
97extern struct _spinlock __stdio_thread_lock __hidden;
98#define STDIO_THREAD_LOCK() \
99do { \
100 if (__isthreaded) \
101 _SPINLOCK(&__stdio_thread_lock); \
102} while (0)
103#define STDIO_THREAD_UNLOCK() \
104do { \
105 if (__isthreaded) \
106 _SPINUNLOCK(&__stdio_thread_lock); \
107} while (0)
108
109void __libc_spinlock_stub(struct _spinlock *);
110void __libc_spinunlock_stub(struct _spinlock *);
111
112/*
113 * Indexes into the pthread jump table.
114 *
115 * Warning! If you change this type, you must also change the threads
116 * libraries that reference it (libc_r, libpthread).
117 */
118typedef enum {
119 PJT_ATFORK,
120 PJT_ATTR_DESTROY,
121 PJT_ATTR_GETDETACHSTATE,
122 PJT_ATTR_GETGUARDSIZE,
123 PJT_ATTR_GETINHERITSCHED,
124 PJT_ATTR_GETSCHEDPARAM,
125 PJT_ATTR_GETSCHEDPOLICY,
126 PJT_ATTR_GETSCOPE,
127 PJT_ATTR_GETSTACKADDR,
128 PJT_ATTR_GETSTACKSIZE,
129 PJT_ATTR_INIT,
130 PJT_ATTR_SETDETACHSTATE,
131 PJT_ATTR_SETGUARDSIZE,
132 PJT_ATTR_SETINHERITSCHED,
133 PJT_ATTR_SETSCHEDPARAM,
134 PJT_ATTR_SETSCHEDPOLICY,
135 PJT_ATTR_SETSCOPE,
136 PJT_ATTR_SETSTACKADDR,
137 PJT_ATTR_SETSTACKSIZE,
138 PJT_CANCEL,
139 PJT_CLEANUP_POP,
140 PJT_CLEANUP_PUSH,
141 PJT_COND_BROADCAST,
142 PJT_COND_DESTROY,
143 PJT_COND_INIT,
144 PJT_COND_SIGNAL,
145 PJT_COND_TIMEDWAIT,
146 PJT_COND_WAIT,
147 PJT_DETACH,
148 PJT_EQUAL,
149 PJT_EXIT,
150 PJT_GETSPECIFIC,
151 PJT_JOIN,
152 PJT_KEY_CREATE,
153 PJT_KEY_DELETE,
154 PJT_KILL,
155 PJT_MAIN_NP,
156 PJT_MUTEXATTR_DESTROY,
157 PJT_MUTEXATTR_INIT,
158 PJT_MUTEXATTR_SETTYPE,
159 PJT_MUTEX_DESTROY,
160 PJT_MUTEX_INIT,
161 PJT_MUTEX_LOCK,
162 PJT_MUTEX_TRYLOCK,
163 PJT_MUTEX_UNLOCK,
164 PJT_ONCE,
165 PJT_RWLOCK_DESTROY,
166 PJT_RWLOCK_INIT,
167 PJT_RWLOCK_RDLOCK,
168 PJT_RWLOCK_TRYRDLOCK,
169 PJT_RWLOCK_TRYWRLOCK,
170 PJT_RWLOCK_UNLOCK,
171 PJT_RWLOCK_WRLOCK,
172 PJT_SELF,
173 PJT_SETCANCELSTATE,
174 PJT_SETCANCELTYPE,
175 PJT_SETSPECIFIC,
176 PJT_SIGMASK,
177 PJT_TESTCANCEL,
178 PJT_CLEANUP_POP_IMP,
179 PJT_CLEANUP_PUSH_IMP,
180 PJT_CANCEL_ENTER,
181 PJT_CANCEL_LEAVE,
182 PJT_MUTEX_CONSISTENT,
183 PJT_MUTEXATTR_GETROBUST,
184 PJT_MUTEXATTR_SETROBUST,
185 PJT_GETTHREADID_NP,
186 PJT_ATTR_GET_NP,
187 PJT_GETNAME_NP,
188 PJT_MAX
189} pjt_index_t;
190
191typedef int (*pthread_func_t)(void);
192typedef pthread_func_t pthread_func_entry_t[2];
193
194extern pthread_func_entry_t __thr_jtable[];
195
196void __set_error_selector(int *(*arg)(void));
197int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
198 void *(calloc_cb)(__size_t, __size_t));
199
200typedef int (*interpos_func_t)(void);
201interpos_func_t *__libc_interposing_slot(int interposno);
202extern interpos_func_t __libc_interposing[] __hidden;
203
204enum {
205 INTERPOS_accept,
206 INTERPOS_accept4,
207 INTERPOS_aio_suspend,
208 INTERPOS_close,
209 INTERPOS_connect,
210 INTERPOS_fcntl,
211 INTERPOS_fsync,
212 INTERPOS_fork,
213 INTERPOS_msync,
214 INTERPOS_nanosleep,
215 INTERPOS_openat,
216 INTERPOS_poll,
217 INTERPOS_pselect,
218 INTERPOS_recvfrom,
219 INTERPOS_recvmsg,
220 INTERPOS_select,
221 INTERPOS_sendmsg,
222 INTERPOS_sendto,
223 INTERPOS_setcontext,
224 INTERPOS_sigaction,
225 INTERPOS_sigprocmask,
226 INTERPOS_sigsuspend,
227 INTERPOS_sigwait,
228 INTERPOS_sigtimedwait,
229 INTERPOS_sigwaitinfo,
230 INTERPOS_swapcontext,
231 INTERPOS_system,
232 INTERPOS_tcdrain,
233 INTERPOS_read,
234 INTERPOS_readv,
235 INTERPOS_wait4,
236 INTERPOS_write,
237 INTERPOS_writev,
238 INTERPOS__pthread_mutex_init_calloc_cb,
239 INTERPOS_spinlock,
240 INTERPOS_spinunlock,
241 INTERPOS_kevent,
242 INTERPOS_wait6,
243 INTERPOS_ppoll,
244 INTERPOS_map_stacks_exec,
245 INTERPOS_fdatasync,
246 INTERPOS_clock_nanosleep,
247 INTERPOS_distribute_static_tls,
248 INTERPOS_pdfork,
249 INTERPOS_MAX
250};
251
252/*
253 * yplib internal interfaces
254 */
255#ifdef YP
256int _yp_check(char **);
257#endif
258
259void __libc_start1(int, char *[], char *[],
260 void (*)(void), int (*)(int, char *[], char *[])) __dead2;
261void __libc_start1_gcrt(int, char *[], char *[],
262 void (*)(void), int (*)(int, char *[], char *[]),
263 int *, int *) __dead2;
264
265/*
266 * Initialise TLS for static programs
267 */
268void _init_tls(void);
269
270/*
271 * Provides pthread_once()-like functionality for both single-threaded
272 * and multi-threaded applications.
273 */
274int _once(pthread_once_t *, void (*)(void));
275
276/*
277 * This is a pointer in the C run-time startup code. It is used
278 * by getprogname() and setprogname().
279 */
280extern const char *__progname;
281
282/*
283 * This function is used by the threading libraries to notify malloc that a
284 * thread is exiting.
285 */
286void _malloc_thread_cleanup(void);
287
288/*
289 * This function is used by the threading libraries to notify libc that a
290 * thread is exiting, so its thread-local dtors should be called.
291 */
292void __cxa_thread_call_dtors(void);
293int __cxa_thread_atexit_hidden(void (*dtor_func)(void *), void *obj,
294 void *dso_symbol) __hidden;
295
296/*
297 * These functions are used by the threading libraries in order to protect
298 * malloc across fork().
299 */
300void _malloc_prefork(void);
301void _malloc_postfork(void);
302
303void _malloc_first_thread(void);
304
305/*
306 * Function to clean up streams, called from abort() and exit().
307 */
308extern void (*__cleanup)(void) __hidden;
309
310/*
311 * Get kern.osreldate to detect ABI revisions. Explicitly
312 * ignores value of $OSVERSION and caches result.
313 */
314int __getosreldate(void);
315#include <sys/_types.h>
316#include <sys/_sigset.h>
317
318struct aiocb;
319struct fd_set;
320struct iovec;
321struct kevent;
322struct msghdr;
323struct pollfd;
324struct rusage;
325struct sigaction;
326struct sockaddr;
327struct stat;
328struct statfs;
329struct timespec;
330struct timeval;
331struct timezone;
332struct __siginfo;
333struct __ucontext;
334struct __wrusage;
335enum idtype;
336int __sys_aio_suspend(const struct aiocb * const[], int,
337 const struct timespec *);
338int __sys_accept(int, struct sockaddr *, __socklen_t *);
339int __sys_accept4(int, struct sockaddr *, __socklen_t *, int);
340int __sys_clock_gettime(__clockid_t, struct timespec *ts);
341int __sys_clock_nanosleep(__clockid_t, int,
342 const struct timespec *, struct timespec *);
343int __sys_close(int);
344int __sys_close_range(unsigned, unsigned, int);
345int __sys_connect(int, const struct sockaddr *, __socklen_t);
346int __sys_fcntl(int, int, ...);
347int __sys_fdatasync(int);
348int __sys_fstat(int fd, struct stat *);
349int __sys_fstatfs(int fd, struct statfs *);
350int __sys_fstatat(int, const char *, struct stat *, int);
351int __sys_fsync(int);
352__pid_t __sys_fork(void);
353int __sys_ftruncate(int, __off_t);
354__ssize_t __sys_getdirentries(int, char *, __size_t, __off_t *);
355int __sys_getfsstat(struct statfs *, long, int);
356int __sys_gettimeofday(struct timeval *, struct timezone *);
357int __sys_kevent(int, const struct kevent *, int, struct kevent *,
358 int, const struct timespec *);
359__off_t __sys_lseek(int, __off_t, int);
360void *__sys_mmap(void *, __size_t, int, int, int, __off_t);
361int __sys_msync(void *, __size_t, int);
362int __sys_nanosleep(const struct timespec *, struct timespec *);
363int __sys_open(const char *, int, ...);
364int __sys_openat(int, const char *, int, ...);
365int __sys_pdfork(int *, int);
366int __sys_pselect(int, struct fd_set *, struct fd_set *,
367 struct fd_set *, const struct timespec *,
368 const __sigset_t *);
369int __sys_ptrace(int, __pid_t, char *, int);
370int __sys_poll(struct pollfd *, unsigned, int);
371int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
372 const __sigset_t *);
373__ssize_t __sys_pread(int, void *, __size_t, __off_t);
374__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
375__ssize_t __sys_read(int, void *, __size_t);
376__ssize_t __sys_readv(int, const struct iovec *, int);
377__ssize_t __sys_recv(int, void *, __size_t, int);
378__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
379 __socklen_t *);
380__ssize_t __sys_recvmsg(int, struct msghdr *, int);
381int __sys_sched_getcpu(void);
382int __sys_select(int, struct fd_set *, struct fd_set *,
383 struct fd_set *, struct timeval *);
384__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
385__ssize_t __sys_sendto(int, const void *, __size_t, int,
386 const struct sockaddr *, __socklen_t);
387int __sys_setcontext(const struct __ucontext *);
388int __sys_sigaction(int, const struct sigaction *,
389 struct sigaction *);
390int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
391int __sys_sigsuspend(const __sigset_t *);
392int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
393 const struct timespec *);
394int __sys_sigwait(const __sigset_t *, int *);
395int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
396int __sys___specialfd(int, const void *, __size_t);
397int __sys_statfs(const char *, struct statfs *);
398int __sys_swapcontext(struct __ucontext *,
399 const struct __ucontext *);
400int __sys_thr_kill(long, int);
401int __sys_thr_self(long *);
402int __sys_truncate(const char *, __off_t);
403__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *);
404__pid_t __sys_wait6(enum idtype, __id_t, int *, int,
405 struct __wrusage *, struct __siginfo *);
406__ssize_t __sys_write(int, const void *, __size_t);
407__ssize_t __sys_writev(int, const struct iovec *, int);
408int __sys_shm_open2(const char *, int, __mode_t, int, const char *);
409
410int __libc_sigaction(int, const struct sigaction *,
411 struct sigaction *) __hidden;
412int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
413 __hidden;
414int __libc_sigsuspend(const __sigset_t *) __hidden;
415int __libc_sigwait(const __sigset_t * __restrict,
416 int * restrict sig);
417int __libc_system(const char *);
418int __libc_tcdrain(int);
419int __fcntl_compat(int fd, int cmd, ...);
420
421int __sys_futimens(int fd, const struct timespec *times) __hidden;
422int __sys_utimensat(int fd, const char *path,
423 const struct timespec *times, int flag) __hidden;
424
425int _elf_aux_info(int aux, void *buf, int buflen);
426struct dl_phdr_info;
427int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
428void __init_elf_aux_vector(void);
429void __libc_map_stacks_exec(void);
430void __libc_distribute_static_tls(__size_t, void *, __size_t, __size_t);
431__uintptr_t __libc_static_tls_base(__size_t);
432
433void _pthread_cancel_enter(int);
434void _pthread_cancel_leave(int);
435
436struct _pthread_cleanup_info;
437void ___pthread_cleanup_push_imp(void (*)(void *), void *,
438 struct _pthread_cleanup_info *);
439void ___pthread_cleanup_pop_imp(int);
440
441void __throw_constraint_handler_s(const char * restrict msg, int error);
442
443struct __nl_cat_d;
444struct _xlocale;
445struct __nl_cat_d *__catopen_l(const char *name, int type,
446 struct _xlocale *locale);
447int __strerror_rl(int errnum, char *strerrbuf, __size_t buflen,
448 struct _xlocale *locale);
449
450#endif /* _LIBC_PRIVATE_H_ */