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