diff options
Diffstat (limited to 'lib/csu/powerpc64')
| -rw-r--r-- | lib/csu/powerpc64/Makefile | 13 | ||||
| -rw-r--r-- | lib/csu/powerpc64/Makefile.depend | 11 | ||||
| -rw-r--r-- | lib/csu/powerpc64/crt.h | 31 | ||||
| -rw-r--r-- | lib/csu/powerpc64/crt1_c.c | 83 | ||||
| -rw-r--r-- | lib/csu/powerpc64/crti.S | 84 | ||||
| -rw-r--r-- | lib/csu/powerpc64/crtn.S | 40 | 
6 files changed, 262 insertions, 0 deletions
| diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile new file mode 100644 index 000000000000..97df3f389115 --- /dev/null +++ b/lib/csu/powerpc64/Makefile @@ -0,0 +1,13 @@ +.PATH: ${.CURDIR:H}/common + +OBJS+=		crtsavres.o +CFLAGS+=	-I${.CURDIR} \ +		-mlongcall + +CLEANFILES+=	crtsavres.S + +# On powerpc64 crtsavres is an empty file +crtsavres.S: +	touch ${.TARGET} + +.include <bsd.lib.mk> diff --git a/lib/csu/powerpc64/Makefile.depend b/lib/csu/powerpc64/Makefile.depend new file mode 100644 index 000000000000..993ab0638f4a --- /dev/null +++ b/lib/csu/powerpc64/Makefile.depend @@ -0,0 +1,11 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ +	include \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/lib/csu/powerpc64/crt.h b/lib/csu/powerpc64/crt.h new file mode 100644 index 000000000000..fd589b9adf37 --- /dev/null +++ b/lib/csu/powerpc64/crt.h @@ -0,0 +1,31 @@ +/*- + * SPDX-License-Identifier: BSD-1-Clause + * + * Copyright 2018 Andrew Turner + * + * 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. + * + * 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. + */ + +#ifndef _CRT_H_ +#define	_CRT_H_ + +#define	HAVE_CTORS +#define	CTORS_CONSTRUCTORS +#define	INIT_CALL_SEQ(func)	"bl " __STRING(func) "; nop" + +#endif diff --git a/lib/csu/powerpc64/crt1_c.c b/lib/csu/powerpc64/crt1_c.c new file mode 100644 index 000000000000..8d389b87a2a5 --- /dev/null +++ b/lib/csu/powerpc64/crt1_c.c @@ -0,0 +1,83 @@ +/* LINTLIBRARY */ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright 2001 David E. O'Brien. + * All rights reserved. + * Copyright 1996-1998 John D. Polstra. + * All rights reserved. + * Copyright (c) 1997 Jason R. Thorpe. + * 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 for the + *          FreeBSD Project.  See https://www.freebsd.org/ for + *          information about FreeBSD. + *          This product includes software developed for the + *          NetBSD Project.  See http://www.netbsd.org/ for + *          information about NetBSD. + * 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/cdefs.h> +#include <stdint.h> +#include <sys/elf.h> + +#include "libc_private.h" +#include "csu_common.h" + +struct Struct_Obj_Entry; +struct ps_strings; + +void _start(int, char **, char **, const struct Struct_Obj_Entry *, +    void (*)(void), struct ps_strings *) __dead2; + +struct ps_strings *__ps_strings; + +/* The entry function. */ +/* + * First 5 arguments are specified by the PowerPC SVR4 ABI. + * The last argument, ps_strings, is a BSD extension. + */ +void +_start(int argc, char **argv, char **env, +    const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), +    struct ps_strings *ps_strings) +{ +	if (ps_strings != (struct ps_strings *)0) +		__ps_strings = ps_strings; + +#ifdef GCRT +	__libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext); +#else +	__libc_start1(argc, argv, env, cleanup, main); +#endif +} + +#ifdef GCRT +__asm__(".text"); +__asm__("eprol:"); +__asm__(".previous"); +#endif diff --git a/lib/csu/powerpc64/crti.S b/lib/csu/powerpc64/crti.S new file mode 100644 index 000000000000..33e9ca4f42ae --- /dev/null +++ b/lib/csu/powerpc64/crti.S @@ -0,0 +1,84 @@ +/*- + * Copyright 2001 David E. O'Brien + * 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. + * + * 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 <machine/asm.h> +#ifdef _CALL_ELF +.abiversion _CALL_ELF +#endif + +	.section .init,"ax",@progbits +	.p2align	2 +	.globl	_init +#if !defined(_CALL_ELF) || _CALL_ELF == 1 +	.section ".opd","aw" +	.p2align	3 +_init: +	.quad	.L._init,.TOC.@tocbase,0 +	.previous +	.type	_init,@function + +	.p2align 4 +.L._init: +#else +	.p2align 4 +	.globl	_init +	.type	_init,@function +_init: +	addis	%r2, %r12, (.TOC.-_init)@ha +	addi	%r2, %r2, (.TOC.-_init)@l +	.localentry _init, .-_init +#endif +	stdu 1,-48(1) +	mflr 0 +	std 0,64(1) + +/* Fini */ +	.section .fini,"ax",@progbits +	.p2align	2 +	.globl	_fini +#if !defined(_CALL_ELF) || _CALL_ELF == 1 +	.section ".opd","aw" +	.p2align	3 +_fini: +	.quad	.L._fini,.TOC.@tocbase,0 +	.previous +	.type	_fini,@function + +	.p2align 4 +.L._fini: +#else +	.p2align 4 +	.globl	_fini +	.type	_fini,@function +_fini: +	addis	%r2, %r12, (.TOC.-_fini)@ha +	addi	%r2, %r2, (.TOC.-_fini)@l +	.localentry _fini, .-_fini +#endif +	stdu 1,-48(1) +	mflr 0 +	std 0,64(1) + +	.section .note.GNU-stack,"",%progbits diff --git a/lib/csu/powerpc64/crtn.S b/lib/csu/powerpc64/crtn.S new file mode 100644 index 000000000000..a7619f3fbf62 --- /dev/null +++ b/lib/csu/powerpc64/crtn.S @@ -0,0 +1,40 @@ +/*- + * Copyright 2001 David E. O'Brien + * 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. + * + * 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 <machine/asm.h> +	.section .init,"ax",@progbits +	ld %r1,0(%r1) +	ld 0,16(%r1) +	mtlr 0 +	blr + + +	.section .fini,"ax",@progbits +	ld %r1,0(%r1) +	ld 0,16(%r1) +	mtlr 0 +	blr + +	.section .note.GNU-stack,"",%progbits | 
