authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-01 00:21:12+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-05 14:52:48+01:00
log4d3a847cd1aaed8587732c1da94e941d6015b050
treef3ce1aa044877f8fd7b3a5e129cdf537db3c191a
parent9f1688653653400b7de3d91cc22dc5036593425a
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libc: add openbsd libc startup code for 7.8


13 files changed, 1009 insertions(+), 0 deletions(-)

lib/libc/openbsd/lib/csu/aarch64/md_init.h created+83
...@@ -0,0 +1,83 @@
1/* $OpenBSD: md_init.h,v 1.12 2023/11/18 16:26:16 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#define MD_SECT_CALL_FUNC(section, func) \
37 __asm (".section "#section", \"ax\" \n" \
38 " bl " #func " \n" \
39 " .previous")
40
41#define MD_SECTION_PROLOGUE(sect, entry_pt) \
42 __asm ( \
43 ".section "#sect",\"ax\",%progbits \n" \
44 " .globl " #entry_pt " \n" \
45 " .type " #entry_pt ",%function \n" \
46 " .align 4 \n" \
47 #entry_pt": \n" \
48 " bti c \n" \
49 " sub sp, sp, #16 \n" \
50 " str lr, [sp] \n" \
51 " /* fall thru */ \n" \
52 " .previous")
53
54
55#define MD_SECTION_EPILOGUE(sect) \
56 __asm ( \
57 ".section "#sect",\"ax\",%progbits \n" \
58 " ldr lr, [sp] \n" \
59 " add sp, sp, #16 \n" \
60 " ret \n" \
61 " .previous")
62
63
64#define MD_CRT0_START \
65 __asm( \
66 ".text \n" \
67 " .align 0 \n" \
68 " .globl _start \n" \
69 " .globl __start \n" \
70 "_start: \n" \
71 "__start: \n" \
72 " bti c \n" \
73 " mov x3, x2 /* cleanup */ \n" \
74 "/* Get argc/argv/envp from stack */ \n" \
75 " ldr x0, [sp] \n" \
76 " add x1, sp, #0x0008 \n" \
77 " add x2, x1, x0, lsl #3 \n" \
78 " add x2, x2, #0x0008 \n" \
79 " \n" \
80 " b ___start \n" \
81 ".previous");
82
83/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/amd64/md_init.h created+80
...@@ -0,0 +1,80 @@
1/* $OpenBSD: md_init.h,v 1.11 2023/11/18 16:26:16 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#define MD_SECT_CALL_FUNC(section, func) \
37 __asm (".section "#section", \"ax\"\n" \
38 " call " #func "\n" \
39 " .previous")
40
41#define MD_SECTION_PROLOGUE(sect, entry_pt) \
42 __asm ( \
43 ".section "#sect",\"ax\",@progbits \n" \
44 " .globl " #entry_pt " \n" \
45 " .type " #entry_pt ",@function \n" \
46 " .align 16 \n" \
47 #entry_pt": \n" \
48 " endbr64 \n" \
49 " subq $8,%rsp \n" \
50 " .previous")
51
52
53#define MD_SECTION_EPILOGUE(sect) \
54 __asm ( \
55 ".section "#sect",\"ax\",@progbits \n" \
56 " addq $8,%rsp \n" \
57 " ret \n" \
58 " .previous")
59
60
61#define MD_CRT0_START \
62 __asm( \
63 ".text \n" \
64 " .align 8 \n" \
65 " .globl __start \n" \
66 " .globl _start \n" \
67 "_start: \n" \
68 "__start: \n" \
69 " endbr64 \n" \
70 " movq %rdx,%rcx \n" \
71 " movq (%rsp),%rdi \n" \
72 " leaq 16(%rsp,%rdi,8),%rdx \n" \
73 " leaq 8(%rsp),%rsi \n" \
74 " subq $8,%rsp \n" \
75 " andq $~15,%rsp \n" \
76 " addq $8,%rsp \n" \
77 " jmp ___start \n" \
78 " .previous")
79
80/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/arm/md_init.h created+112
...@@ -0,0 +1,112 @@
1/* $OpenBSD: md_init.h,v 1.19 2024/08/17 09:48:31 phessler Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/*
37 * arm overrides these because it uses %progbits instead of @progbits
38 */
39#define MD_DATA_SECTION_FLAGS_SYMBOL(section, flags, type, symbol) \
40 extern __dso_hidden type symbol[]; \
41 __asm(" .section "section",\""flags"\",%progbits \n" \
42 " .balign 4 \n" \
43 #symbol": \n" \
44 " .previous")
45#define MD_DATA_SECTION_SYMBOL_VALUE(section, type, symbol, value) \
46 extern __dso_hidden type symbol[]; \
47 __asm(" .section "section",\"aw\",%progbits \n" \
48 " .balign 4 \n" \
49 #symbol": \n" \
50 " .int "#value" \n" \
51 " .previous")
52#define MD_DATA_SECTION_FLAGS_VALUE(section, flags, value) \
53 __asm(" .section "section",\""flags"\",%progbits \n" \
54 " .balign 4 \n" \
55 " .int "#value" \n" \
56 " .previous")
57
58#define MD_SECT_CALL_FUNC(section, func) \
59 __asm (".section "#section", \"ax\" \n" \
60 " movw r0, #:lower16:" #func "- 1f - 8 \n" \
61 " movt r0, #:upper16:" #func "- 1f - 8 \n" \
62 "1: add r0, r0, pc \n" \
63 " blx r0 \n" \
64 " .previous")
65
66#define MD_SECTION_PROLOGUE(sect, entry_pt) \
67 __asm ( \
68 ".section "#sect",\"ax\",%progbits \n" \
69 " .globl " #entry_pt " \n" \
70 " .type " #entry_pt ",%function \n" \
71 " .align 4 \n" \
72 #entry_pt": \n" \
73 " push {r4, lr} \n" \
74 " /* fall thru */ \n" \
75 " .previous")
76
77
78#define MD_SECTION_EPILOGUE(sect) \
79 __asm ( \
80 ".section "#sect",\"ax\",%progbits \n" \
81 " pop {r4, pc} \n" \
82 " .previous")
83
84
85/*
86 * The definitions of environ and __progname prevent the creation
87 * of COPY relocations for WEAK symbols.
88 */
89#define MD_CRT0_START \
90 __asm( \
91 ".text \n" \
92 " .align 0 \n" \
93 " .globl _start \n" \
94 " .globl __start \n" \
95 "_start: \n" \
96 "__start: \n" \
97 " mov r3, r0 /* cleanup */ \n" \
98 "/* Get argc/argv/envp from stack */ \n" \
99 " ldr r0, [sp, #0] \n" \
100 " add r1, sp, #4 \n" \
101 " add r2, r1, r0, lsl #2 \n" \
102 " add r2, r2, #4 \n" \
103 " \n" \
104 "/* \n" \
105 " * Ensure the stack is properly \n" \
106 " * aligned before calling C code. \n" \
107 " */ \n" \
108 " bic sp, sp, #7" /*__STRING(STACKALIGNBYTES)*/ " \n" \
109 " b ___start \n" \
110 ".previous");
111
112/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/crt0.c created+76
...@@ -0,0 +1,76 @@
1/* $OpenBSD: crt0.c,v 1.19 2025/05/24 06:32:12 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1995 Christopher G. Demetriou
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/syscall.h>
35#include <stdlib.h>
36#include <limits.h>
37
38#include "md_init.h"
39/* zig patch: no static crt support */
40#include "extern.h"
41
42#define STR(x) __STRING(x) /* shorter macro name for MD_RCRT0_START */
43
44/* some defaults */
45#ifndef MD_START_ARGS
46#define MD_START_ARGS \
47 int argc, char **argv, char **envp, void (*cleanup)(void)
48#endif
49static void ___start(MD_START_ARGS) __used;
50#ifndef MD_EPROL_LABEL
51#define MD_EPROL_LABEL __asm(" .text\n_eprol:")
52#endif
53
54char ***_csu_finish(char **_argv, char **_envp, void (*_cleanup)(void));
55
56/* zig patch: no profiling support */
57
58#ifdef MD_CRT0_START
59MD_CRT0_START;
60#endif
61
62/* zig patch: no legacy leanup abi support */
63
64static void
65___start(MD_START_ARGS)
66{
67 size_t size, i;
68 char ***environp;
69#ifdef MD_START_SETUP
70 MD_START_SETUP
71#endif
72
73 environp = _csu_finish(argv, envp, cleanup);
74
75 exit(main(argc, argv, *environp));
76}
lib/libc/openbsd/lib/csu/crtbegin.c created+61
...@@ -0,0 +1,61 @@
1/* $OpenBSD: crtbegin.c,v 1.26 2019/01/09 16:42:38 visa Exp $ */
2/* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */
3
4/*
5 * Copyright (c) 1993 Paul Kranenburg
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 by Paul Kranenburg.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Run-time module for GNU C++ compiled shared libraries.
36 *
37 * The linker constructs the following arrays of pointers to global
38 * constructors and destructors. The first element contains the
39 * number of pointers in each.
40 * The tables are also null-terminated.
41 */
42#include <stdlib.h>
43
44#include "md_init.h"
45#include "os-note-elf.h"
46#include "extern.h"
47
48/* zig patch: no ctors/dtors and init/fini */
49
50/*
51 * Include support for the __cxa_atexit/__cxa_finalize C++ abi for
52 * gcc > 2.x. __dso_handle is NULL in the main program and a unique
53 * value for each C++ shared library. For more info on this API, see:
54 *
55 * http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor
56 */
57
58void *__dso_handle = NULL;
59__asm(".hidden __dso_handle");
60
61long __guard_local __dso_hidden __attribute__((section(".openbsd.randomdata")));
lib/libc/openbsd/lib/csu/extern.h created+54
...@@ -0,0 +1,54 @@
1/*
2 * Copyright (c) 2004 Marc Espie <espie@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17void __init(void) __dso_hidden;
18int main(int argc, char *argv[], char *envp[]);
19
20typedef const void *dl_cb_cb(int);
21typedef void (*initarray_f)(int, char **, char **, dl_cb_cb *);
22typedef void (*init_f)(void);
23
24/*
25 * Provide default implementations of these. Only archs with weird
26 * ASM stuff (hppa, arm) need to override them
27 */
28#ifndef MD_DATA_SECTION_FLAGS_SYMBOL
29# ifdef __LP64__
30# define VALUE_ALIGN ".balign 8"
31# define VALUE_DIRECTIVE ".quad"
32# else
33# define VALUE_ALIGN ".balign 4"
34# define VALUE_DIRECTIVE ".int"
35# endif
36# define MD_DATA_SECTION_FLAGS_SYMBOL(section, flags, type, symbol) \
37 extern __dso_hidden type symbol[]; \
38 __asm(" .section "section",\""flags"\",@progbits \n" \
39 " "VALUE_ALIGN" \n" \
40 #symbol": \n" \
41 " .previous")
42# define MD_DATA_SECTION_SYMBOL_VALUE(section, type, symbol, value) \
43 extern __dso_hidden type symbol[]; \
44 __asm(" .section "section",\"aw\",@progbits \n" \
45 " "VALUE_ALIGN" \n" \
46 #symbol": \n" \
47 " "VALUE_DIRECTIVE" "#value" \n" \
48 " .previous")
49# define MD_DATA_SECTION_FLAGS_VALUE(section, flags, value) \
50 __asm(" .section "section",\""flags"\",@progbits \n" \
51 " "VALUE_ALIGN" \n" \
52 " "VALUE_DIRECTIVE" "#value" \n" \
53 " .previous")
54#endif
lib/libc/openbsd/lib/csu/i386/md_init.h created+83
...@@ -0,0 +1,83 @@
1/* $OpenBSD: md_init.h,v 1.13 2023/11/18 16:26:16 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#define MD_SECT_CALL_FUNC(section, func) \
37 __asm (".section "#section", \"ax\"\n" \
38 " call " #func "\n" \
39 " .previous")
40
41#define MD_SECTION_PROLOGUE(sect, entry_pt) \
42 __asm ( \
43 ".section "#sect",\"ax\",@progbits \n" \
44 " .globl " #entry_pt " \n" \
45 " .type " #entry_pt ",@function \n" \
46 " .align 16 \n" \
47 #entry_pt": \n" \
48 " pushl %ebp \n" \
49 " movl %esp,%ebp \n" \
50 " andl $~15,%esp \n" \
51 " .previous")
52
53
54#define MD_SECTION_EPILOGUE(sect) \
55 __asm ( \
56 ".section "#sect",\"ax\",@progbits \n" \
57 " leave \n" \
58 " ret \n" \
59 " .previous")
60
61
62#define MD_CRT0_START \
63 __asm( \
64 ".text \n" \
65 " .align 4 \n" \
66 " .globl __start \n" \
67 " .globl _start \n" \
68 "_start: \n" \
69 "__start: \n" \
70 " movl %esp,%ebp \n" \
71 " andl $~15,%esp # align stack\n" \
72 " pushl %edx # cleanup\n" \
73 " movl 0(%ebp),%eax \n" \
74 " leal 8(%ebp,%eax,4),%ecx \n" \
75 " leal 4(%ebp),%edx \n" \
76 " pushl %ecx \n" \
77 " pushl %edx \n" \
78 " pushl %eax \n" \
79 " xorl %ebp,%ebp # mark deepest stack frame\n" \
80 " call ___start \n" \
81 " .previous")
82
83/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/mips64/md_init.h created+127
...@@ -0,0 +1,127 @@
1/* $OpenBSD: md_init.h,v 1.22 2023/11/19 00:46:54 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
5 * Copyright (c) 2001 Simon Burge
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 by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/*
38 * Allocate 32 bytes for the stack frame. Store GP at SP+16 (since
39 * this is where code generated by the compiler for fallthru processing
40 * expects it to be), and the RA at SP+24.
41 */
42
43/* this is gross... */
44
45#ifdef __ABICALLS__
46#define MD_FUNCTION_PROLOGUE(entry_pt) \
47 " .frame $sp,32,$31 \n" \
48 " .set reorder \n" \
49 " dsubu $sp,$sp,32 \n" \
50 " .cpsetup $25, 16, "#entry_pt" \n" \
51 " sd $ra ,24($sp) \n"
52#else
53#define MD_FUNCTION_PROLOGUE(entry_pt) \
54 " dsubu $sp,$sp,32 \n" \
55 " sd $ra ,24($sp) \n"
56#endif
57
58
59#define MD_SECTION_PROLOGUE(sect, entry_pt) \
60 __asm ( \
61 ".section "#sect",\"ax\",@progbits \n" \
62 ".align 2 \n" \
63 ".globl "#entry_pt" \n" \
64 ".type "#entry_pt",@function \n" \
65 ".ent "#entry_pt" \n" \
66 #entry_pt": \n" \
67 MD_FUNCTION_PROLOGUE(entry_pt) \
68 " /* fall thru */ \n" \
69 ".end "#entry_pt" \n" \
70 ".previous")
71
72#define MD_SECTION_EPILOGUE(sect) \
73 __asm ( \
74 ".section "#sect",\"ax\",@progbits \n" \
75 " ld $ra ,24($sp) \n" \
76 " # next should have been a .cpreturn \n" \
77 " ld $gp,16($sp) \n" \
78 " .set noreorder \n" \
79 " j $ra \n" \
80 " daddu $sp,$sp,32 \n" \
81 " .set reorder \n" \
82 ".previous")
83
84#define MD_SECT_CALL_FUNC(section, func) \
85 __asm (".section "#section", \"ax\" \n" \
86 " .local " #func " \n" \
87 " jal " #func " \n" \
88 ".previous")
89
90#define MD_CRT0_START \
91 __asm( \
92 ".text \n" \
93 " .align 3 \n" \
94 " .globl __start \n" \
95 " .ent __start \n" \
96 " .type __start, @function \n" \
97 "__start: \n" \
98 " lui $gp, %hi(%neg(%gp_rel(__start))) \n" \
99 " addiu $gp, $gp, %lo(%neg(%gp_rel(__start))) \n" \
100 " daddu $gp, $gp, $t9 \n" \
101 " move $a0, $sp \n" \
102 " dsrl $a1, $sp, 4 \n" /* align stack on a */ \
103 " dsll $sp, $a1, 4 \n" /* 16 byte boundary */ \
104 " move $a1, $v0 \n" \
105 " .local ___start \n" \
106 " dla $t9, ___start \n" \
107 " jr $t9 \n" \
108 " .end __start \n" \
109 " .previous")
110
111/* zig patch: no static crt support */
112
113struct kframe {
114 long kargc;
115 char *kargv[1]; /* size depends on kargc */
116 char kargstr[1]; /* size varies */
117 char kenvstr[1]; /* size varies */
118};
119
120#define MD_START_ARGS struct kframe *kfp, void (*cleanup)(void)
121#define MD_START_SETUP \
122 char **argv, **envp; \
123 long argc; \
124 \
125 argc = kfp->kargc; \
126 argv = &kfp->kargv[0]; \
127 envp = argv + argc + 1;
lib/libc/openbsd/lib/csu/os-note-elf.h created+19
...@@ -0,0 +1,19 @@
1/* $OpenBSD: os-note-elf.h,v 1.5 2009/03/06 23:13:40 kurt Exp $ */
2/*
3 * Contents:
4 *
5 * long Name length
6 * long Description length
7 * long ELF_NOTE_TYPE_OSVERSION (1) XXX - need a define.
8 * "OpenBSD\0"
9 * version? 0 XXX
10 */
11
12__asm(" .section \".note.openbsd.ident\", \"a\"\n"
13" .p2align 2\n"
14" .long 8\n"
15" .long 4\n"
16" .long 1\n"
17" .ascii \"OpenBSD\\0\"\n"
18" .long 0\n"
19" .previous\n");
lib/libc/openbsd/lib/csu/powerpc/md_init.h created+80
...@@ -0,0 +1,80 @@
1/* $OpenBSD: md_init.h,v 1.12 2023/11/18 16:26:16 deraadt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#define MD_SECT_CALL_FUNC(section, func) \
37 __asm (".section "#section", \"ax\"\n" \
38 " bl " #func "\n" \
39 " .previous")
40
41#define MD_SECTION_PROLOGUE(sect, entry_pt) \
42 __asm ( \
43 ".section "#sect",\"ax\",@progbits \n" \
44 " .globl " #entry_pt " \n" \
45 " .type " #entry_pt ",@function \n" \
46 " .align 4 \n" \
47 #entry_pt": \n" \
48 " stwu %r1,-16(%r1) \n" \
49 " mflr %r0 \n" \
50 " stw %r0,12(%r1) \n" \
51 " /* fall thru */ \n" \
52 " .previous")
53
54
55#define MD_SECTION_EPILOGUE(sect) \
56 __asm ( \
57 ".section "#sect",\"ax\",@progbits \n" \
58 " lwz %r0,12(%r1) \n" \
59 " mtlr %r0 \n" \
60 " addi %r1,%r1,16 \n" \
61 " blr \n" \
62 " .previous")
63
64#define MD_CRT0_START \
65__asm( \
66" .text \n" \
67" .section \".text\" \n" \
68" .align 2 \n" \
69" .globl _start \n" \
70" .type _start, @function \n" \
71" .globl __start \n" \
72" .type __start, @function \n" \
73"_start: \n" \
74"__start: \n" \
75" # put cleanup in r6 instead of r7 \n" \
76" mr %r6, %r7 \n" \
77" b ___start \n" \
78)
79
80/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/powerpc64/md_init.h created+75
...@@ -0,0 +1,75 @@
1/* $OpenBSD: md_init.h,v 1.5 2023/11/18 16:26:16 deraadt Exp $ */
2
3/*
4 * Copyright (c) 2020 Dale Rahn <drahn@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#define MD_SECT_CALL_FUNC(section, func) \
20 __asm (".section "#section", \"ax\" \n" \
21 " bl " #func " \n" \
22 " .previous")
23
24#define MD_SECTION_PROLOGUE(sect, entry_pt) \
25 __asm ( \
26 ".section "#sect",\"ax\",@progbits \n" \
27 " .globl " #entry_pt " \n" \
28 " .type " #entry_pt ",@function \n" \
29 " .align 4 \n" \
30 #entry_pt": \n" \
31 ".L_"sect"_gep: \n" \
32 " addis %r2, %r12, .TOC.-.L_"sect"_gep@ha \n" \
33 " addi %r2, %r2, .TOC.-.L_"sect"_gep@l \n" \
34 ".L_"sect"_lep: \n" \
35 " .localentry " #entry_pt", .L_"sect"_lep-.L_"sect"_gep; \n" \
36 " mflr %r0 \n" \
37 " std %r0,16(%r1) \n" \
38 " stdu %r1,-64(%r1) \n" \
39 " /* fall thru */ \n" \
40 " .previous")
41
42
43#define MD_SECTION_EPILOGUE(sect) \
44 __asm ( \
45 ".section "#sect",\"ax\",@progbits \n" \
46 " addi %r1,%r1,64 \n" \
47 " ld %r0,16(%r1) \n" \
48 " mtlr %r0 \n" \
49 " blr \n" \
50 " .previous")
51
52#define MD_CRT0_START \
53__asm( \
54" .text \n" \
55" .section \".text\" \n" \
56" .align 2 \n" \
57" .globl _start \n" \
58" .type _start, @function \n" \
59" .globl __start \n" \
60" .type __start, @function \n" \
61"_start: \n" \
62"__start: \n" \
63" bl 1f \n" \
64"1: \n" \
65" mflr %r30 \n" \
66" addis %r2, %r30, .TOC.-1b@ha \n" \
67" addi %r2, %r2, .TOC.-1b@l \n" \
68" # put cleanup in r6 instead of r7 \n" \
69" mr %r6, %r7 \n" \
70" li %r7, 0 \n" \
71" stdu %r7, -64(%r1) \n" \
72" b ___start \n" \
73)
74
75/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/riscv64/md_init.h created+74
...@@ -0,0 +1,74 @@
1/* $OpenBSD: md_init.h,v 1.4 2023/11/18 16:26:16 deraadt Exp $ */
2/*
3 * Copyright (c) 2020 Dale Rahn <drahn@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#define MD_SECT_CALL_FUNC(section, func) \
19 __asm (".section "#section", \"ax\" \n" \
20 "call " # func "@plt \n" \
21 " .previous")
22
23#define MD_SECTION_PROLOGUE(sect, entry_pt) \
24 __asm ( \
25 ".section "#sect",\"ax\",%progbits \n" \
26 " .globl " #entry_pt " \n" \
27 " .type " #entry_pt ",@function \n" \
28 " .align 4 \n" \
29 #entry_pt": \n" \
30 " addi sp, sp, -16 \n" \
31 " sd ra,8(sp) \n" \
32 " sd s0,0(sp) \n" \
33 " addi s0, sp, 16 \n" \
34 " /* fall thru */ \n" \
35 " .previous")
36
37
38#define MD_SECTION_EPILOGUE(sect) \
39 __asm ( \
40 ".section "#sect",\"ax\",%progbits \n" \
41 " ld ra, 8(sp) \n" \
42 " ld s0, 0(sp) \n" \
43 " addi sp, sp, 16 \n" \
44 " jr ra \n" \
45 " .previous")
46
47
48#define MD_CRT0_START \
49 __asm( \
50 ".text \n" \
51 " .align 0 \n" \
52 " .globl _start \n" \
53 " .globl __start \n" \
54 " .type _start, @function \n" \
55 " .type __start, @function \n" \
56 "_start: \n" \
57 "__start: \n" \
58 "/* Get argc/argv/envp from stack */ \n" \
59 " ld a0, (sp) \n" \
60 " addi a1, sp, 0x8 \n" \
61 " slli t0, a0, 0x3 \n" \
62 " add a2, a1, t0 \n" \
63 " addi a2, a2, 0x8 \n" \
64 " \n" \
65 " addi sp, sp, -16 \n" \
66 " li t0, 0 \n" \
67 " sd t0,(sp) \n" \
68 " \n" \
69 " j ___start \n" \
70 " .size _start, .-_start \n" \
71 " .size __start, .-__start \n" \
72 ".previous");
73
74/* zig patch: no static crt support */
lib/libc/openbsd/lib/csu/sparc64/md_init.h created+85
...@@ -0,0 +1,85 @@
1/* $OpenBSD: md_init.h,v 1.11 2025/01/30 21:41:37 kurt Exp $ */
2
3/*-
4 * Copyright (c) 2001 Ross Harvey
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#define MD_SECT_CALL_FUNC(section, func) \
37 __asm (".section "#section", \"ax\" \n" \
38 " call " #func " \n" \
39 " nop \n" \
40 " .previous")
41
42#define MD_SECTION_PROLOGUE(sect, entry_pt) \
43 __asm ( \
44 ".section "#sect",\"ax\",@progbits \n" \
45 " .globl " #entry_pt " \n" \
46 " .type " #entry_pt ",@function \n" \
47 #entry_pt": \n" \
48 " save %sp, -192, %sp \n" \
49 " .align 4 \n" \
50 " /* fall thru */ \n" \
51 " .previous")
52
53
54#define MD_SECTION_EPILOGUE(sect) \
55 __asm ( \
56 ".section "#sect",\"ax\",@progbits \n" \
57 " ret \n" \
58 " restore \n" \
59 " .previous")
60
61
62#define MD_CRT0_START \
63 __asm__( \
64 ".text \n" \
65 " .align 4 \n" \
66 " .global _start \n" \
67 " .global __start \n" \
68 "_start: \n" \
69 "__start: \n" \
70 " clr %fp \n" \
71 " add %sp, 2175, %o0 /* stack */\n" \
72 " ba,pt %icc, ___start \n" \
73 " mov %g1, %o1 \n" \
74 " .previous")
75
76/* zig patch: no static crt support */
77
78#define MD_START_ARGS char **sp, void (*cleanup)(void)
79#define MD_START_SETUP \
80 char **argv, **envp; \
81 long argc; \
82 \
83 argc = *(long *)sp; \
84 argv = sp + 1; \
85 envp = sp + 2 + argc; /* 2: argc + NULL ending argv */