Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
2013-12-06 12:04:52 +01:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379317 additions and 151059 deletions

View File

@@ -1,24 +1,21 @@
# $NetBSD: Makefile,v 1.31 2012/06/16 19:19:14 joerg Exp $
# $NetBSD: Makefile,v 1.33 2013/09/10 16:45:33 matt Exp $
.include <bsd.own.mk>
LD+= ${${HAVE_GOLD:Uno} != "no":? --script ${LDS_RELOC}:}
.if ${USE_COMPILERCRTSTUFF} != "yes"
.if defined(CSU_MACHINE_ARCH)
. if !exists(${.CURDIR}/arch/${CSU_MACHINE_ARCH}/Makefile.inc)
. error CSU_MACHINE_ARCH (${CSU_MACHINE_ARCH}) is unsupported
. endif
.elif exists(${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc)
CSU_MACHINE_ARCH= ${MACHINE_ARCH}
CSU_MACHINE_ARCH?= ${MACHINE_ARCH}
.if !empty(CSU_MACHINE_ARCH:Mearm*)
ARCHDIR:= ${.CURDIR}/arch/earm
.elif exists(${.CURDIR}/arch/${CSU_MACHINE_ARCH}/Makefile.inc)
ARCHDIR:= ${.CURDIR}/arch/${CSU_MACHINE_ARCH}
.elif exists(${.CURDIR}/arch/${MACHINE_CPU}/Makefile.inc)
CSU_MACHINE_ARCH= ${MACHINE_CPU}
ARCHDIR:= ${.CURDIR}/arch/${MACHINE_CPU}
.else
.error Architecture (${MACHINE_ARCH} or ${MACHINE_CPU}) unsupported
.error Architecture (${CSU_MACHINE_ARCH} or ${MACHINE_CPU}) unsupported
.endif
ARCHDIR:= ${.CURDIR}/arch/${CSU_MACHINE_ARCH}
.PATH: ${ARCHDIR}
. include "${ARCHDIR}/Makefile.inc"

View File

@@ -1,3 +1,26 @@
Introduction
This document covers the native NetBSD compiler runtime. The full support
for the native runtime is enabled by setting USE_COMPILERCRTSTUFF to no
in bsd.own.mk.
Machine independent sources can be found in common. The crtbegin.c in
that directory is a useful template for deriving compact assembler
versions. That is preferable to decouple the result from changes in the
compiler logic.
A new platform should provide the following content in
arch/${MACHINE_ARCH} or arch/${MACHINE_CPU}:
- Makefile.inc: provides ELFSIZE corresponding to 32/64bit file format.
If using the common C code instead of crtbegin.S also provide a -I option
to find crtbegin.h in your arch subdir.
- crt0.S: provides setup code and the call to ___start.
- crtbegin.S or crtbegin.h: see below
- crtend.S: see below, most likely just a copy of an existing architecture
- crti.S: prefix part of .init/.fini sections, i.e. to ensure stack alignment
- crtn.S: suffix part of the .init/.fini sections, i.e. return to caller.
Overview of the common runtime support
The common runtime support contains two modules, crtbegin and crtend.
@@ -61,3 +84,10 @@ Deinitialisation (called from .fini):
Call the pointers as void (*)(void) functions.
5. If __deregister_frame_info is NULL, return.
6. Call __deregister_frame_info with the start of .eh_frame as the argument.
Since most of this can easily be done in C code, instead of providing a
crtbegin.S you can also chose to use the generic C implementation. Provide
a crtbegin.h file instead of crtbegin.S. In there put inline assembler
stubs (mostly copied from some other arch) and implement calls to the
helper functions __do_global_ctors_aux/__do_global_dtors_aux.

View File

@@ -0,0 +1,3 @@
# $NetBSD: Makefile.inc,v 1.1 2013/07/11 16:40:27 matt Exp $
CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=64

54
lib/csu/arch/alpha/crt0.S Normal file
View File

@@ -0,0 +1,54 @@
/* $NetBSD: crt0.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <alpha/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2013/07/11 16:40:27 matt Exp $")
STRONG_ALIAS(_start,__start)
/*
* Assumes kernel (or ld_elf.so) passes the following parameters to
* user-space in registers:
*
* a0 stack pointer
* a1 cleanup
* a2 Obj_Entry
* a3 ps_strings
*/
LEAF(__start, 4)
LDGP(pv)
mov a1, a0 /* cleanup */
mov a2, a1 /* Obj_Entry */
mov a3, a2 /* ps_strings */
CALL(___start)
END(__start)

View File

@@ -0,0 +1,50 @@
/* $NetBSD: crtbegin.h,v 1.1 2013/07/11 16:40:27 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <sys/cdefs.h>
#include <alpha/asm.h>
/* Assume we need to reload our GP. */
__asm( ".pushsection .init"
"\n\t" "br $29, 1f"
"\n\t" "1: ldgp $29, 0($29)"
"\n\t" "unop"
"\n\t" "jsr $26, __do_global_ctors_aux"
"\n\t" ".p2align 3"
"\n\t" ".popsection");
/* Assume we need to reload our GP. */
__asm( ".pushsection .fini"
"\n\t" "br $29, 1f"
"\n\t" "1: ldgp $29, 0($29)"
"\n\t" "unop"
"\n\t" "jsr $26, __do_global_dtors_aux"
"\n\t" ".p2align 3"
"\n\t" ".popsection");

View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <alpha/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 16:40:27 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 3
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.word 0
.section .dtors, "aw", @progbits
.p2align 3
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.word 0
.section .eh_frame, "a", @progbits
.p2align 3
.word 0
.section .jcr, "aw", @progbits
.p2align 3
.word 0

View File

@@ -0,0 +1,68 @@
/* $NetBSD: crtfm.c,v 1.1 2013/08/05 13:38:35 matt Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
*
* 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 NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
/*
* Support for the GCC "-ffast-math" option on the Alpha.
*/
#include <sys/types.h>
#include <machine/fpu.h>
#include <machine/sysarch.h>
/*
* Must provide this wrapper around sysarch(2) so that statically-linked
* programs work properly.
*/
extern void __alpha_sysarch(int, void *);
__asm(".ent __alpha_sysarch 0 ;\n"
"__alpha_sysarch: ;\n"
" ldiq $0, 165 ;\n" /* v0 = SYS_sysarch */
" call_pal 0x0083 ;\n" /* PAL_OSF1_callsys */
" ret $31,($26),1 ;\n"
".end __alpha_sysarch");
static void __attribute__((__constructor__))
__alpha_set_fast_math(void)
{
struct alpha_fp_c_args args;
args.fp_c = IEEE_MAP_DMZ|IEEE_MAP_UMZ;
__alpha_sysarch(ALPHA_SET_FP_C, &args);
}

55
lib/csu/arch/alpha/crti.S Normal file
View File

@@ -0,0 +1,55 @@
/* $NetBSD: crti.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <alpha/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2013/07/11 16:40:27 matt Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.global _init
.type _init, @function
_init:
LDGP(pv)
lda sp, -32(sp)
stq ra, 0(sp)
stq gp, 8(sp)
.p2align 5
.section ".fini", "ax", @progbits
.global _fini
.type _fini, @function
_fini:
LDGP(pv)
lda sp, -32(sp)
stq ra, 0(sp)
stq gp, 8(sp)
.p2align 5

45
lib/csu/arch/alpha/crtn.S Normal file
View File

@@ -0,0 +1,45 @@
/* $NetBSD: crtn.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <alpha/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2013/07/11 16:40:27 matt Exp $")
.section ".init", "ax", @progbits
ldq gp, 8(sp)
ldq ra, 0(sp)
lda sp, 32(sp)
RET
.section ".fini", "ax", @progbits
ldq gp, 8(sp)
ldq ra, 0(sp)
lda sp, 32(sp)
RET

View File

@@ -1,3 +1,7 @@
# $NetBSD: Makefile.inc,v 1.2 2012/09/16 13:46:49 skrll Exp $
# $NetBSD: Makefile.inc,v 1.7 2013/09/10 22:00:01 matt Exp $
CPPFLAGS+= -DELFSIZE=32
CPPFLAGS+= -I${ARCHDIR}
.if (!empty(CPUFLAGS) && ${CPUFLAGS:M-mabi=aapcs*} != "")
CPPFLAGS+= -DHAVE_INITFINI_ARRAY
.endif
CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

View File

@@ -1,293 +0,0 @@
/* $NetBSD: crtbegin.S,v 1.4 2012/08/25 15:39:05 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <arm/asm.h>
RCSID("$NetBSD: crtbegin.S,v 1.4 2012/08/25 15:39:05 matt Exp $")
.section .ctors, "aw", %progbits
.p2align 2
__CTOR_LIST__:
.word -1
.section .dtors, "aw", %progbits
.p2align 2
__DTOR_LIST__:
.word -1
.section .eh_frame, "a", %progbits
.p2align 2
__EH_FRAME_LIST__:
.section .jcr, "aw", %progbits
.p2align 2
__JCR_LIST__:
.section .data.rel, "aw", %progbits
.p2align 2
.type __dso_handle, %object
.size __dso_handle, 4
.globl __dso_handle
.hidden __dso_handle
__dso_handle:
#ifdef SHARED
.word __dso_handle
#else
.word 0
#endif
.local __dwarf_eh_object
.comm __dwarf_eh_object,24
.local __initialized
.comm __initialized,1
.local __finished
.comm __finished,1
.text
/*
* All variables are local to this DSO so we can skip using GOT references
* and instead use PCREL references to access them. We do this regardless
* of being PIC since it isn't any additional overhead to do so.
*
* We don't setup a TOC since all of ours calls are indirect so it isn't
* needed.
*/
.type __do_global_dtors_aux, %function
__do_global_dtors_aux:
GOT_INIT(r3, .Ldtors_got, .Ldtors) /* use r3 temporarily */
ldr r1, .L__finished
#ifdef PIC
ldrb r0, [r1, r3]!
#else
ldrb r0, [r1]
#endif
cmp r0, #0 /* done this already? */
RETc(ne)
mov r0, #1
strb r0, [r1] /* mark it as done */
mov ip, sp
stmfd sp!, {r4, r5, r6, r7, fp, ip, lr, pc}
sub fp, ip, #4
mov r7, r3 /* now that r7 is saved ... */
#ifdef SHARED
GOT_GET(ip, r7, .L__cxa_finalize)
cmp ip, #0
ldrne r2, .L__dso_handle /* GOTOFF */
ldrne r0, [r2, r7] /* load relative to GOT */
#ifdef _ARM_ARCH_4T
blxne ip
#else
movne lr, pc
movne pc, ip
#endif
#endif /* SHARED */
/*
* We know the first entry is -1 so skip it. We use load with
* preincrement to advance the pointer along.
*/
ldr r4, .L__DTOR_LIST__
ldr r5, .L__DTOR_LIST_END__
#ifdef PIC
add r4, r4, r7 /* addr = offset + got */
add r5, r5, r7 /* addr = offset + got */
#endif
add r4, r4, #4 /* skip first entry */
1:
cmp r4, r5 /* end of list */
ldrne ip, [r4], #4 /* ip = *r4++; */
#ifndef SHARED
ldmeqfd sp, {r4, r5, r6, r7, fp, sp, pc} /* restore and return */
#endif
adrne lr, 1b /* set up to return to loop start */
#ifdef _ARM_ARCH_4T
bxne ip /* call it */
#else
movne pc, ip /* call entry */
#endif
#ifdef SHARED
/*
* if (__deregister_frame_info)
* __deregister_frame_info(&__EH_FRAME_LIST__[0]);
*/
GOT_GET(ip, r7, .L__deregister_frame_info)
cmp ip, #0
ldmeqfd sp, {r4-r7, fp, sp, pc} /* restore and return */
ldr r1, .L__EH_FRAME_LIST__
#ifdef PIC
add r0, r1, r7 /* add offset to GOT addr */
#endif
ldmfd sp, {r4-r7, fp, sp, lr} /* restore everthing */
#ifdef _ARM_ARCH_4T
bx ip /* tail call it */
#else
mov pc, ip /* tail call it */
#endif
#endif /* SHARED */
.weak __deregister_frame_info
.weak __cxa_finalize
.hidden _C_LABEL(__DTOR_LIST_END__)
.align 2
GOT_INITSYM(.Ldtors_got, .Ldtors)
#ifdef SHARED
.L__deregister_frame_info:
.word PIC_SYM(_C_LABEL(__deregister_frame_info), GOT)
.L__cxa_finalize:
.word PIC_SYM(_C_LABEL(__cxa_finalize), GOT)
.L__dso_handle:
.word PIC_SYM(_C_LABEL(__dso_handle), GOTOFF)
#endif
.L__finished:
.word PIC_SYM(_C_LABEL(__finished), GOTOFF)
.L__DTOR_LIST__:
.word PIC_SYM(_C_LABEL(__DTOR_LIST__), GOTOFF)
.L__DTOR_LIST_END__:
.word PIC_SYM(_C_LABEL(__DTOR_LIST_END__), GOTOFF)
.L__EH_FRAME_LIST__:
.word PIC_SYM(_C_LABEL(__EH_FRAME_LIST__), GOTOFF)
.weak __register_frame_info
.weak _Jv_RegisterClasses
.type __do_global_ctors_aux, %function
__do_global_ctors_aux:
GOT_INIT(r3, .Lctors_got, .Lctors)
ldr r1, .L__initialized
#ifdef PIC
ldrb r0, [r1, r3]!
#else
ldrb r0, [r1]
#endif
cmp r0, #0 /* done this already? */
RETc(ne)
mov r0, #1
strb r0, [r1] /* mark it as done */
mov ip, sp
stmfd sp!, {r4, r5, r6, r7, fp, ip, lr, pc}
sub fp, ip, #4
mov r7, r3 /* now that r7 is saved ... */
/*
* if (__register_frame_info)
* __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
*/
GOT_GET(ip, r7, .L__register_frame_info)
cmp ip, #0
beq 1f
ldr r0, .L__EH_FRAME_LIST__
ldr r1, .L__dwarf_eh_object
#ifdef PIC
add r0, r0, r7 /* object addr = got addr + offset */
add r1, r1, r7 /* object addr = got addr + offset */
#endif
#ifdef _ARM_ARCH_4T
blx ip
#else
mov lr, pc
mov pc, ip
#endif
1:
/*
* if (_Jv_RegisterClasses && __JCR_LIST__[0])
* _Jv_RegisterClasses(&__JCR_LIST__[0]);
*/
GOT_GET(ip, r7, .L_Jv_RegisterClasses)
cmp ip, #0
ldrne r0, .L__JCR_LIST__
#ifdef PIC
ldrne r2, [r0, r7]! /* load 1st one, make r0 point to it */
#else
ldrne r2, [r0] /* load 1st one */
#endif
cmpne r2, #0
#ifdef _ARM_ARCH_4T
blxne ip
#else
movne lr, pc
movne pc, ip
#endif
/*
* Get the start and end of the CTOR list.
*/
ldr r4, .L__CTOR_LIST__
ldr r5, .L__CTOR_LIST_END__
#ifdef PIC
add r4, r4, r7 /* object addr = got addr + offset */
add r5, r5, r7 /* object addr = got addr + offset */
#endif
sub r5, r5, #4 /* ignore first entry */
3:
cmp r4, r5 /* at first entry? */
ldmeqfd sp, {r4-r7, fp, sp, pc} /* then return */
adr lr, 3b /* return to start of loop */
ldr ip, [r5], #-4 /* get entry */
#ifdef _ARM_ARCH_4T
bx ip
#else
mov pc, ip /* get entry */
#endif
.hidden _C_LABEL(__CTOR_LIST_END__)
.align 2
GOT_INITSYM(.Lctors_got, .Lctors)
.L_Jv_RegisterClasses:
.word PIC_SYM(_C_LABEL(_Jv_RegisterClasses), GOT)
.L__register_frame_info:
.word PIC_SYM(_C_LABEL(__register_frame_info), GOT)
.L__initialized:
.word PIC_SYM(_C_LABEL(__initialized), GOTOFF)
.L__CTOR_LIST__:
.word PIC_SYM(_C_LABEL(__CTOR_LIST__), GOTOFF)
.L__CTOR_LIST_END__:
.word PIC_SYM(_C_LABEL(__CTOR_LIST_END__), GOTOFF)
.L__dwarf_eh_object:
.word PIC_SYM(_C_LABEL(__dwarf_eh_object), GOTOFF)
.L__JCR_LIST__:
.word PIC_SYM(_C_LABEL(__JCR_LIST__), GOTOFF)
.section .init, "ax", %progbits
bl __do_global_ctors_aux
.section .fini, "ax", %progbits
bl __do_global_dtors_aux

View File

@@ -0,0 +1,38 @@
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm(
".pushsection .init, \"ax\", %progbits"
"\n\t" "bl __do_global_ctors_aux"
"\n\t" ".popsection");
__asm(
".pushsection .fini, \"ax\", %progbits"
"\n\t" "bl __do_global_dtors_aux"
"\n\t" ".popsection");

View File

@@ -1,5 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2012/08/13 02:49:04 matt Exp $
# $NetBSD: Makefile.inc,v 1.3 2013/09/10 16:45:33 matt Exp $
CPPFLAGS+= -DELFSIZE=32
CPPFLAGS+= -I${ARCHDIR}
CPPFLAGS+= -DHAVE_INITFINI_ARRAY
CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $ */
/* $NetBSD: crt0.S,v 1.3 2013/09/05 00:27:38 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <arm/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
RCSID("$NetBSD: crt0.S,v 1.3 2013/09/05 00:27:38 matt Exp $")
STRONG_ALIAS(_start,__start)
@@ -44,7 +44,14 @@ _ENTRY(__start)
mov r2, ip /* tmp -> ps_strings */
/* Ensure the stack is properly aligned before calling C code. */
#if !defined(__thumb__)
bic sp, sp, #7
#else
movs r6, #7
mov r7, sp
bics r7, r7, r6
mov sp, r7
#endif
/*
* void ___start(void (*cleanup)(void),

View File

@@ -1,216 +0,0 @@
/* $NetBSD: crtbegin.S,v 1.1 2012/08/13 02:49:04 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <arm/asm.h>
RCSID("$NetBSD: crtbegin.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
.section .eh_frame, "a", %progbits
.p2align 2
__EH_FRAME_LIST__:
.section .jcr, "aw", %progbits
.p2align 2
__JCR_LIST__:
.section .data.rel, "aw", %progbits
.p2align 2
.type __dso_handle, %object
.size __dso_handle, 4
.globl __dso_handle
.hidden __dso_handle
__dso_handle:
#ifdef SHARED
.word __dso_handle
#else
.word 0
#endif
.text
#ifdef SHARED
/*
* If we aren't shared, all we do is set finished
* to 1 if it isn't 1 already. So why bother do that at all?
*/
.type __do_global_dtors_aux, %function
__do_global_dtors_aux:
GOT_INIT(r3, .Ldtors_got, .Ldtors) /* use r3 temporarily */
ldr r1, .L__finished /* GOTOFF */
ldrb r0, [r1, r3]!
cmp r0, #0 /* done this already? */
RETc(ne)
mov r0, #1
strb r0, [r1] /* mark it as done */
GOT_GET(ip, r3, .L__cxa_finalize)
cmp ip, #0
RETc(eq)
ldr r0, .L__dso_handle /* GOTOFF */
ldr r0, [r0, r3] /* load relative to got */
#if defined(_ARM_ARCH_4T)
bx ip /* tail call */
#else
mov pc, ip
#endif
#if 0 /* not used */
/*
* if (__deregister_frame_info)
* __deregister_frame_info(&__EH_FRAME_LIST__[0]);
*/
GOT_GET(ip, r3, .L__deregister_frame_info)
cmp ip, #0
ldmeqfd sp, {r4, r5, fp, sp, pc} /* restore and return */
ldr r1, .L__EH_FRAME_LIST__ /* GOTOFF */
add r1, r1, r4 /* add got addr */
ldmfd sp, {r4, r5, fp, sp, lr} /* restore everthing */
#if !defined(_ARM_ARCH_4T)
bx ip /* tail call it */
#else
mov pc, ip /* tail call it */
#endif
#endif /* notused */
.weak __cxa_finalize
.weak __deregister_frame_info
.align 2
GOT_INITSYM(.Ldtors_got, .Ldtors)
.L__cxa_finalize:
.word PIC_SYM(_C_LABEL(__cxa_finalize), GOT)
#if 0
.L__deregister_frame_info:
.word PIC_SYM(_C_LABEL(__deregister_frame_info), GOT)
#endif
.L__finished:
.word PIC_SYM(_C_LABEL(__finished), GOTOFF)
.L__dso_handle:
.word PIC_SYM(_C_LABEL(__dso_handle), GOTOFF)
.pushsection .fini_array,"aw",%fini_array
.p2align 2
.word __do_global_dtors_aux
.popsection
#endif /* SHARED */
.local __finished
.comm __finished,1,1
.weak __register_frame_info
.weak _Jv_RegisterClasses
.type __do_global_ctors_aux, %function
__do_global_ctors_aux:
GOT_INIT(r3, .Lctors_got, .Lctors)
ldr r1, .L__initialized /* GOTOFF if PIC */
#ifdef PIC
ldrb r0, [r1, r3]! /* r1 = r1 + got */
#else
ldrb r0, [r1]
#endif
cmp r0, #0 /* done this already? */
RETc(ne)
mov r0, #1
strb r0, [r1] /* mark it as done */
mov ip, sp
stmfd sp!, {r4, r5, fp, ip, lr, pc}
sub fp, ip, #4
mov r4, r3 /* now that r4 is saved ... */
/*
* if (__register_frame_info)
* __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
*/
GOT_GET(ip, r4, .L__register_frame_info)
cmp ip, #0
beq 1f
ldr r0, .L__EH_FRAME_LIST__
ldr r1, .L__dwarf_eh_object
#ifdef PIC
add r0, r0, r4
add r1, r1, r4
#endif
#if defined(_ARM_ARCH_4T)
blx ip
#else
mov lr, pc
mov pc, ip
#endif
1:
/*
* if (_Jv_RegisterClasses && __JCR_LIST__[0])
* _Jv_RegisterClasses(&__JCR_LIST__[0]);
*/
GOT_GET(ip, r4, .L_Jv_RegisterClasses)
cmp ip, #0
ldmeqfd sp, {r4, r5, fp, sp, pc} /* return if null */
ldr r0, .L__JCR_LIST__
#ifdef PIC
ldr r2, [r0, r4]! /* GOTOFF + got == address */
#else
ldr r2, [r0]
#endif
cmp r2, #0
ldmfd sp, {r4, r5, fp, sp, lr} /* restore everything */
RETc(eq) /* return if null */
#if defined(_ARM_ARCH_4T)
bx ip /* return or tail call */
#else
mov pc, ip /* return or tail call */
#endif
.p2align 2
GOT_INITSYM(.Lctors_got, .Lctors)
.L__register_frame_info:
.word PIC_SYM(_C_LABEL(__register_frame_info), GOT)
.L_Jv_RegisterClasses:
.word PIC_SYM(_C_LABEL(_Jv_RegisterClasses), GOT)
.L__initialized:
.word PIC_SYM(_C_LABEL(__initialized), GOTOFF)
.L__EH_FRAME_LIST__:
.word PIC_SYM(_C_LABEL(__EH_FRAME_LIST__), GOTOFF)
.L__dwarf_eh_object:
.word PIC_SYM(_C_LABEL(__dwarf_eh_object), GOTOFF)
.L__JCR_LIST__:
.word PIC_SYM(_C_LABEL(__JCR_LIST__), GOTOFF)
.local __initialized
.comm __initialized,1,1
.local __dwarf_eh_object
.comm __dwarf_eh_object,24,4
.section .init_array,"aw",%init_array
.p2align 2
.word __do_global_ctors_aux

View File

@@ -0,0 +1,50 @@
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used;
#ifdef SHARED
static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used;
#endif
#ifndef SHARED
static const void *find_exidx(void *, int *) __used;
static const void *
find_exidx(void * pc, int * pcount)
{
extern __dso_hidden const char __exidx_start[];
extern __dso_hidden const char __exidx_end[];
*pcount = (__exidx_end - __exidx_start) / 8;
return __exidx_start;
}
__weak_alias(__gnu_Uwind_find_exidx,find_exidx)
#endif /* !SHARED */

View File

@@ -0,0 +1,3 @@
# $NetBSD: Makefile.inc,v 1.1 2013/07/13 18:52:35 skrll Exp $
CPPFLAGS+= -DELFSIZE=32 -I${ARCHDIR}

67
lib/csu/arch/hppa/crt0.S Normal file
View File

@@ -0,0 +1,67 @@
/* $NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* 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 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
.import _GLOBAL_OFFSET_TABLE_
.hidden ___start
STRONG_ALIAS(__start,_start)
/*
* void _start(struct ps_strings *ps_strings,
* void (*cleanup)(void),
* const Obj_Entry *obj);
*/
_ENTRY(_start)
.callinfo frame=0, calls
.entry
bl L$lpc, %r27
depi 0, 31, 2, %r27
L$lpc: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8), %r27
ldo R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%r1),%r27
copy %r27, %r19
/*
* void ___start(void (*cleanup)(void),
* const Obj_Entry *obj,
* struct ps_strings *ps_strings);
*/
copy %arg0, %arg3 ; ps_strings -> tmp
copy %arg1, %arg0 ; cleanup -> arg0
copy %arg2, %arg1 ; obj -> arg1
b ___start
copy %arg3, %arg2 ; ps_strings (tmp) -> arg2
EXIT(_start)

View File

@@ -0,0 +1,43 @@
/* $NetBSD*/
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* 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 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.
*/
__asm( "\n\t"
".pushsection .init, \"ax\", @progbits" "\n\t"
"bl __do_global_ctors_aux, %rp" "\n\t"
" nop" "\n\t"
".popsection");
__asm( "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
"bl __do_global_dtors_aux, %rp" "\n\t"
" nop" "\n\t"
".popsection");

View File

@@ -0,0 +1,56 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
.section .ctors, "aw", @progbits
.align 4
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.long 0
.section .dtors, "aw", @progbits
.align 4
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits
.align 4
.long 0
.section .jcr, "aw", @progbits
.align 4
.long 0

55
lib/csu/arch/hppa/crti.S Normal file
View File

@@ -0,0 +1,55 @@
/* $NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* 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 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
#include "sysident.S"
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
.section sect,"ax",@progbits ! \
.global entry_pt ! \
.proc ! \
.callinfo frame=HPPA_FRAME_SIZE, calls, save_rp, save_sp, entry_gr=3 ! \
.entry ! \
entry_pt: ! \
stw %rp, HPPA_FRAME_CRP(%sp) ! \
copy %r3, %r1 ! \
copy %sp, %r3 ! \
stw,ma %r1, HPPA_FRAME_SIZE(%sp) ! \
/* fall thru */ ! \
.exit ! \
.procend ! \
.previous
MD_SECTION_PROLOGUE(.init, _init)
MD_SECTION_PROLOGUE(.fini, _fini)

46
lib/csu/arch/hppa/crtn.S Normal file
View File

@@ -0,0 +1,46 @@
/* $NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* 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 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
#define MD_SECTION_EPILOGUE(sect) \
.section #sect,"ax",@progbits ! \
ldw HPPA_FRAME_CRP(%r3) ,%rp ! \
ldo HPPA_FRAME_SIZE(%r3), %sp ! \
ldw,mb -HPPA_FRAME_SIZE(%sp), %r3 ! \
bv,n %r0(%rp) ! \
.previous
MD_SECTION_EPILOGUE(.init)
MD_SECTION_EPILOGUE(.fini)

View File

@@ -1,5 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:34 joerg Exp $
# $NetBSD: Makefile.inc,v 1.2 2013/07/11 17:07:35 matt Exp $
CPPFLAGS+= -DELFSIZE=32
CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=32

View File

@@ -35,18 +35,14 @@
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
RCSID("$NetBSD: crt0.S,v 1.4 2013/07/26 19:49:19 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
movl (%sp),%d0
movl %a2,-(%sp) | ps_strings
movl %a0,-(%sp) | obj
movl %a1,-(%sp) | cleanup
movl %d0,%d1
lsll #2,%d1
pea (16+4)(%sp,%d1.l) | envp = &argv[argc + 1]
pea 20(%sp) | argv
movl %d0,-(%sp) | argc
jsr ___start
| call: ___start(cleanup, obj, ps_strings)
jbsr ___start
END(__start)

View File

@@ -0,0 +1,45 @@
/* $NetBSD: crtbegin.h,v 1.4 2013/07/27 13:07:06 martin Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( ".pushsection .init"
#ifdef __pic__
"\n\t" "bsrl __do_global_ctors_aux"
#else
"\n\t" "jsr __do_global_ctors_aux"
#endif
"\n\t" ".popsection");
__asm( ".pushsection .fini"
#ifdef __pic__
"\n\t" "bsrl __do_global_dtors_aux"
#else
"\n\t" "jsr __do_global_dtors_aux"
#endif
"\n\t" ".popsection");

View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/11 17:07:35 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <m68k/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 17:07:35 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 2
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.long 0
.section .dtors, "aw", @progbits
.p2align 2
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits
.p2align 2
.long 0
.section .jcr, "aw", @progbits
.p2align 2
.long 0

View File

@@ -0,0 +1,3 @@
# $NetBSD: Makefile.inc,v 1.2 2013/07/10 15:05:46 matt Exp $
CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=_MIPS_SZPTR

58
lib/csu/arch/mips/crt0.S Normal file
View File

@@ -0,0 +1,58 @@
/* $NetBSD: crt0.S,v 1.2 2013/06/25 16:47:47 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <mips/asm.h>
RCSID("$NetBSD: crt0.S,v 1.2 2013/06/25 16:47:47 matt Exp $")
STRONG_ALIAS(_start,__start)
/*
* Assumes kernel (or ld_elf.so) passes the following parameters to
* user-space in registers:
*
* a0 stack pointer (0 if setregs didn't fill this in)
* a1 cleanup
* a2 Obj_Entry
* a3 ps_strings
*
* XXX Does this violate the ABI?
* as well as the usual registers (pc, sp, and t9 == pc for ABI).
*/
NESTED_NOPROFILE(__start, CALLFRAME_SIZ, ra)
SETUP_GP
SETUP_GP64(t3, __start)
move a0, a1 /* cleanup */
move a1, a2 /* Obj_Entry */
move a2, a3 /* ps_strings */
j _C_LABEL(___start)
END(__start)

View File

@@ -0,0 +1,66 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( "\n\t"
".pushsection .init, \"ax\", @progbits" "\n\t"
#ifdef __mips_o32
".set noreorder" "\n\t"
".set nomacro" "\n\t"
"move $28,$16" "\n\t"
"lw $25,%got(__do_global_ctors_aux)($28)" "\n\t"
"nop" "\n\t"
"addiu $25,$25,%lo(__do_global_ctors_aux)" "\n\t"
".reloc 1f,R_MIPS_JALR,__do_global_ctors_aux" "\n\t"
"1: jalr $25" "\n\t"
"nop" "\n\t"
".set macro" "\n\t"
".set reorder" "\n\t"
#else
"jal __do_global_ctors_aux" "\n\t"
#endif
".popsection");
__asm( "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
#ifdef __mips_o32
".set noreorder" "\n\t"
".set nomacro" "\n\t"
"move $28,$16" "\n\t"
"lw $25,%got(__do_global_dtors_aux)($28)" "\n\t"
"nop" "\n\t"
"addiu $25,$25,%lo(__do_global_dtors_aux)" "\n\t"
".reloc 1f,R_MIPS_JALR,__do_global_dtors_aux" "\n\t"
"1: jalr $25" "\n\t"
"nop" "\n\t"
".set macro" "\n\t"
".set reorder" "\n\t"
#else
"jal __do_global_dtors_aux" "\n\t"
#endif
".popsection");

View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <mips/asm.h>
RCSID("$NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $")
.section .ctors, "aw", @progbits
.p2align PTR_SCALESHIFT
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.word 0
.section .dtors, "aw", @progbits
.p2align PTR_SCALESHIFT
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.word 0
.section .eh_frame, "aw", @progbits
.p2align PTR_SCALESHIFT
.space _MIPS_SZPTR / 8
.section .jcr, "aw", @progbits
.p2align PTR_SCALESHIFT
.space _MIPS_SZPTR / 8

60
lib/csu/arch/mips/crti.S Normal file
View File

@@ -0,0 +1,60 @@
/* $NetBSD: crti.S,v 1.2 2013/06/30 08:00:34 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <mips/asm.h>
RCSID("$NetBSD: crti.S,v 1.2 2013/06/30 08:00:34 matt Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
NESTED_NOPROFILE(_init, CALLFRAME_SIZ, ra)
SETUP_GP
PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame
REG_S ra, CALLFRAME_RA(sp) # save RA
#ifdef __mips_o32
REG_S s0, CALLFRAME_S0(sp) # save s0
move s0, gp
#endif
SETUP_GP64(CALLFRAME_GP, _init)
END(_init)
.section ".fini", "ax", @progbits
NESTED_NOPROFILE(_fini, CALLFRAME_SIZ, ra)
SETUP_GP
PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame
REG_S ra, CALLFRAME_RA(sp) # save RA
#ifdef __mips_o32
REG_S s0, CALLFRAME_S0(sp) # save s0
move s0, gp
#endif
SETUP_GP64(CALLFRAME_GP, _fini)
END(_fini)

52
lib/csu/arch/mips/crtn.S Normal file
View File

@@ -0,0 +1,52 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <mips/asm.h>
RCSID("$NetBSD: crtn.S,v 1.2 2013/06/30 08:00:34 matt Exp $")
.section ".init", "ax", @progbits
REG_L ra, CALLFRAME_RA(sp)
#if defined(__mips_o32) || defined(__mips_o64)
REG_L s0, CALLFRAME_S0(sp)
#else
REG_L gp, CALLFRAME_GP(sp)
#endif
PTR_ADDU sp, sp, CALLFRAME_SIZ
jr ra
.section ".fini", "ax", @progbits
REG_L ra, CALLFRAME_RA(sp)
#ifdef __mips_o32
REG_L s0, CALLFRAME_S0(sp)
#else
REG_L gp, CALLFRAME_GP(sp)
#endif
PTR_ADDU sp, sp, CALLFRAME_SIZ
jr ra

View File

@@ -1,5 +1,3 @@
# $NetBSD: Makefile.inc,v 1.1 2011/02/08 02:02:25 matt Exp $
CPPFLAGS+= -DELFSIZE=32
# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $
CPPFLAGS+= -I${ARCHDIR}

View File

@@ -1,268 +0,0 @@
/* $NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <powerpc/asm.h>
RCSID("$NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 2
__CTOR_LIST__:
.long -1
.section .dtors, "aw", @progbits
.p2align 2
__DTOR_LIST__:
.long -1
.section .eh_frame, "a", @progbits
.p2align 2
__EH_FRAME_LIST__:
.section .jcr, "aw", @progbits
.p2align 2
__JCR_LIST__:
.section ".got2","aw", @progbits
.LCTOC = . + 32768
.section .data.rel, "aw", @progbits
.p2align 2
.type __dso_handle, @object
.size __dso_handle, 4
.globl __dso_handle
.hidden __dso_handle
__dso_handle:
#ifdef SHARED
.long __dso_handle
#else
.long 0
#endif
.lcomm __dwarf_eh_object,8*SZREG,SZREG
.lcomm __initialized,1,1
.lcomm __finished,1,1
.text
.weak __cxa_finalize
.weak __deregister_frame_info
.weak __register_frame_info
.weak _Jv_RegisterClasses
/*
* All variables are local to this DSO so we can skip using GOT references
* and instead use PCREL references to access them. We do this regardless
* of being PIC since it isn't any additional overhead to do so.
*
* We don't setup a TOC since all of ours calls are indirect so it isn't
* needed.
*/
__do_global_dtors_aux:
mflr %r7 /* save return address */
bcl 20,31,1f /* find out what address */
1: mflr %r3 /* we are at */
mtlr %r7 /* restore return address */
addis %r4,%r3,__finished-1b@ha /* PCREL ref (upper) */
lbzu %r0,__finished-1b@l(%r4) /* PCREL ref (lower) & load */
cmpwi %r0,0 /* done this already? */
bnelr /* yep, return */
li %r0, 1
stb %r0, 0(%r4) /* remember we've done this */
stw %r7,(1*SZREG)(%r1) /* save LR */
stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
stw %r31,(7*SZREG)(%r1) /* save some registers */
stw %r30,(6*SZREG)(%r1)
stw %r29,(5*SZREG)(%r1)
stw %r28,(4*SZREG)(%r1)
mr %r29,%r3 /* move this to a safe place */
/*
* Get a reference to our TOC.
*/
addis %r30,%r29,.LCTOC-1b@ha
addi %r30,%r30,.LCTOC-1b@l
/*
* Get a reference to the GOT.
*/
addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
#ifdef SHARED
/*
* if (__cxa_finalize)
* __cxa_finalize(&__dso_handle);
*/
lwz %r0, __cxa_finalize@got(%r31)
cmpwi %r0, 0
beq 2f
addis %r3,%r29,__dso_handle-1b@ha /* get &__dso_handle (pcrel) */
addi %r3,%r3,__dso_handle-1b@l
mtctr %r0 /* setup for indirect branch */
bctrl /* and call the routine */
2:
#endif
addis %r28,%r29,__DTOR_LIST__-1b@ha /* get &__DTOR_LIST__ */
addi %r28,%r28,__DTOR_LIST__-1b@l
/*
* We know the first entry is -1 so skip it. We use load with update
* to advance the pointer along.
*/
3:
lwzu %r0, 4(%r28) /* get entry */
cmpwi %r0, 0 /* end of list? */
beq 4f /* yep. */
mtctr %r0 /* setup for indirect branch */
bctrl /* and call the routine */
b 3b /* do it again */
4:
/*
* if (__deregister_frame_info)
* __deregister_frame_info(&__EH_FRAME_LIST__[0]);
*/
lwz %r0,__deregister_frame_info@got(%r31)
cmpwi %r0, 0 /* routine actually exist? */
beq 5f /* nope, skip call */
addis %r3,%r29,__EH_FRAME_LIST__-1b@ha
addi %r3,%r3,__EH_FRAME_LIST__-1b@l
mtctr %r0 /* setup for indirect branch */
bctrl /* and call the routine */
5:
lwz %r28,(4*SZREG)(%r1) /* restore registers */
lwz %r29,(5*SZREG)(%r1)
lwz %r30,(6*SZREG)(%r1)
lwz %r31,(7*SZREG)(%r1)
addi %r1,%r1,8*SZREG /* adjust stack */
lwz %r0,(1*SZREG)(%r1) /* get return addr */
mtlr %r0
blr /* and return */
__do_global_ctors_aux:
mflr %r7 /* save return address */
bcl 20,31,1f /* find out what address */
1: mflr %r3 /* we are at */
mtlr %r7 /* restore return address */
addis %r4,%r3,__initialized-1b@ha /* pcrel (hi) */
lbzu %r0,__initialized-1b@l(%r4) /* pcrel (lo) load+update */
cmpwi %r0,0 /* have we already done this? */
bnelr /* yep, return */
li %r0,1
stb %r0,0(%r4) /* remember we've been here */
stw %r7,(1*SZREG)(%r1) /* save LR */
stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
stw %r31,(7*SZREG)(%r1) /* save some registers */
stw %r30,(6*SZREG)(%r1)
stw %r29,(5*SZREG)(%r1)
stw %r28,(4*SZREG)(%r1)
mr %r29,%r3 /* move this to a safe place */
/*
* Get a reference to our TOC.
*/
addis %r30,%r29,.LCTOC-1b@ha
addi %r30,%r30,.LCTOC-1b@l
/*
* Get a reference to the GOT.
*/
addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
/*
* if (__register_frame_info)
* __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
*/
lwz %r0, __register_frame_info@got(%r31)
cmpwi %r0, 0
beq 2f
addis %r3,%r29,__EH_FRAME_LIST__-1b@ha /* pcrel (hi) */
addi %r3,%r3,__EH_FRAME_LIST__-1b@l /* pcrel (lo) */
addis %r4,%r29,__dwarf_eh_object-1b@ha /* pcrel (hi) */
addi %r4,%r4,__dwarf_eh_object-1b@l /* pcrel (lo) */
mtctr %r0 /* setup for indirect branch */
bctrl /* and call the routine */
2:
/*
* if (_Jv_RegisterClasses && __JCR_LIST__[0])
* _Jv_RegisterClasses(&__JCR_LIST__[0]);
*/
lwz %r0, _Jv_RegisterClasses@got(%r31)
cmpwi %r0, 0
beq 3f
mtctr %r0 /* setup for indirect branch */
addis %r3, %r29, __JCR_LIST__-1b@ha /* pcrel (hi) */
addi %r3, %r3, __JCR_LIST__-1b@l /* pcrel (lo) */
lwz %r4, 0(%r3) /* load first entry */
cmpwi %r4, 0 /* is the list empty? */
bnectrl /* call the routine if not */
3:
/*
* Get end of list of CTOR list.
*/
addis %r28,%r29,__CTOR_LIST_END__-1b@ha
addi %r28,%r28,__CTOR_LIST_END__-1b@l
4:
lwzu %r0, -4(%r28) /* get entry */
cmpwi %r0, -1 /* first entry? */
beq 5f /* yes, we're done */
mtctr %r0 /* setup for indirect branch */
bctrl /* call the routine */
b 4b /* do it again */
5:
lwz %r28,(4*SZREG)(%r1) /* restore registers */
lwz %r29,(5*SZREG)(%r1)
lwz %r30,(6*SZREG)(%r1)
lwz %r31,(7*SZREG)(%r1)
addi %r1,%r1,8*SZREG /* adjust stack */
lwz %r0,(1*SZREG)(%r1) /* get return addr */
mtlr %r0
blr /* and return */
.section .init, "ax", @progbits
bl __do_global_ctors_aux
.section .fini, "ax", @progbits
bl __do_global_dtors_aux

View File

@@ -0,0 +1,36 @@
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( ".pushsection .init, \"ax\", @progbits"
"\n\t" "bl __do_global_ctors_aux"
"\n\t" ".popsection");
__asm( ".pushsection .fini, \"ax\", @progbits"
"\n\t" "bl __do_global_dtors_aux"
"\n\t" ".popsection");

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $ */
/* $NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -30,7 +30,7 @@
#include <powerpc/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
RCSID("$NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 2
@@ -41,6 +41,9 @@ __CTOR_LIST_END__:
.section .dtors, "aw", @progbits
.p2align 2
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe Exp $ */
/* $NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $ */
/*-
* Copyright (c) 2012 Valeriy E. Ushakov
* All rights reserved.
@@ -30,7 +30,7 @@
#include <machine/asm.h>
RCSID("$NetBSD: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe Exp $")
RCSID("$NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $")
.section .ctors, "aw", @progbits
.p2align 2
@@ -84,7 +84,7 @@ __finished:
* address and only r0 can be used in @(r0, Rm) addressing mode, so we
* always load variable address to r0.
*/
#ifdef PIC
#ifdef __PIC__
#define VAR_DATUM(var) var@GOTOFF
#define FUNC_DATUM(f) f@GOT
#define R0VAR (r0, r12)
@@ -98,7 +98,7 @@ __finished:
__do_global_ctors_aux:
mov.l r8, @-sp
mov.l r9, @-sp
#ifdef PIC
#ifdef __PIC__
mov.l r12, @-sp
mov.l .Lc_got, r12
mova .Lc_got, r0
@@ -121,7 +121,7 @@ __do_global_ctors_aux:
!! if (__register_frame_info)
!! __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
#ifdef PIC
#ifdef __PIC__
mov.l .Lc___register_frame_info_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
@@ -146,7 +146,7 @@ __do_global_ctors_aux:
!! if (_Jv_RegisterClasses && __JCR_LIST__[0])
!! _Jv_RegisterClasses(&__JCR_LIST__[0]);
#ifdef PIC
#ifdef __PIC__
mov.l .Lc__Jv_RegisterClasses_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
@@ -183,7 +183,7 @@ __do_global_ctors_aux:
!! call all constructors on __CTOR_LIST__ in reverse order
mov.l .Lc___CTOR_LIST_END__, r8
#ifdef PIC
#ifdef __PIC__
add r12, r8
#endif
add #-4, r8
@@ -203,7 +203,7 @@ __do_global_ctors_aux:
mov r14, sp
lds.l @sp+, pr
mov.l @sp+, r14
#ifdef PIC
#ifdef __PIC__
mov.l @sp+, r12
#endif
mov.l @sp+, r9
@@ -215,7 +215,7 @@ __do_global_ctors_aux:
PIC_GOT_DATUM
.Lc___initialized:
.long VAR_DATUM(__initialized)
#ifdef PIC
#ifdef __PIC__
.Lc___register_frame_info_GOT:
.long __register_frame_info@GOT
#endif
@@ -225,7 +225,7 @@ __do_global_ctors_aux:
.long VAR_DATUM(__EH_FRAME_LIST__)
.Lc___dwarf_eh_object:
.long VAR_DATUM(__dwarf_eh_object)
#ifdef PIC
#ifdef __PIC__
.Lc__Jv_RegisterClasses_GOT:
.long _Jv_RegisterClasses@GOT
#endif
@@ -240,7 +240,7 @@ __do_global_ctors_aux:
__do_global_dtors_aux:
mov.l r8, @-sp
mov.l r9, @-sp
#ifdef PIC
#ifdef __PIC__
mov.l r12, @-sp
mov.l .Ld_got, r12
mova .Ld_got, r0
@@ -277,7 +277,7 @@ __do_global_dtors_aux:
!! call all destructors on __DTOR_LIST__
mov.l .Ld___DTOR_LIST__, r8
#ifdef PIC
#ifdef __PIC__
add r12, r8
#endif
add #4, r8 ! skip first entry that we know to be -1
@@ -293,7 +293,7 @@ __do_global_dtors_aux:
!! if (__deregister_frame_info)
!! __deregister_frame_info(&__EH_FRAME_LIST__[0]);
#ifdef PIC
#ifdef __PIC__
mov.l .Ld___deregister_frame_info_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
@@ -317,7 +317,7 @@ __do_global_dtors_aux:
mov r14, sp
lds.l @sp+, pr
mov.l @sp+, r14
#ifdef PIC
#ifdef __PIC__
mov.l @sp+, r12
#endif
mov.l @sp+, r9
@@ -339,7 +339,7 @@ __do_global_dtors_aux:
#endif
.Ld___DTOR_LIST__:
.long VAR_DATUM(__DTOR_LIST__)
#ifdef PIC
#ifdef __PIC__
.Ld___deregister_frame_info_GOT:
.long __deregister_frame_info@GOT
#endif

View File

@@ -1,5 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:34 joerg Exp $
# $NetBSD: Makefile.inc,v 1.2 2013/07/11 06:57:15 martin Exp $
CPPFLAGS+= -DELFSIZE=32
CPPFLAGS+= -DELFSIZE=32 -I${ARCHDIR}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/* $NetBSD: crt0.S,v 1.2 2013/07/11 06:57:15 martin Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -37,20 +37,21 @@
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
RCSID("$NetBSD: crt0.S,v 1.2 2013/07/11 06:57:15 martin Exp $")
STRONG_ALIAS(_start,__start)
! called with:
! %g3 = cleanup
! %g2 = obj
! %g1 = ps_strings
! call: ___start(cleanup, obj, ps_strings)
_ENTRY(__start)
mov 0, %fp
ld [%sp + 64], %o0 ! get argc
add %sp, 68, %o1 ! get argv
sll %o0, 2, %o2 !
add %o2, 4, %o2 ! envp = argv + (argc << 2) + 4
add %o1, %o2, %o2 !
andn %sp, 7, %sp ! align
andn %sp, 7, %sp ! align stack
sub %sp, 24, %sp ! expand to standard stack frame size
mov %g3, %o3
mov %g2, %o4
mov %g3, %o0
mov %g2, %o1
call ___start
mov %g1, %o5
mov %g1, %o2

View File

@@ -0,0 +1,40 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( "\n\t"
".pushsection .init, \"ax\", @progbits" "\n\t"
"call __do_global_ctors_aux" "\n\t"
" nop" "\n\t"
".popsection");
__asm( "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
"call __do_global_dtors_aux" "\n\t"
" nop" "\n\t"
".popsection");

View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $")
.section .ctors, "aw", @progbits
.align 4
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.long 0
.section .dtors, "aw", @progbits
.align 4
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits
.align 4
.long 0
.section .jcr, "aw", @progbits
.align 4
.long 0

View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2013/07/11 06:57:15 martin Exp $
CPPFLAGS+= -DELFSIZE=64 -I${ARCHDIR}

View File

@@ -0,0 +1,60 @@
/* $NetBSD: crt0.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
* 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
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2013/07/11 06:57:15 martin Exp $")
STRONG_ALIAS(_start,__start)
.align 4
.register %g3,#scratch
.register %g2,#scratch
! called with:
! %g3 = cleanup
! %g2 = obj
! %g1 = ps_strings
! call: ___start(cleanup, obj, ps_strings)
_ENTRY(__start)
clr %fp
clr %g4 ! data base for some memory models
mov %g3, %o0
mov %g2, %o1
ba,pt %icc,___start
mov %g1, %o2

View File

@@ -0,0 +1,40 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( "\n\t"
".pushsection .init, \"ax\", @progbits" "\n\t"
"call __do_global_ctors_aux" "\n\t"
" nop" "\n\t"
".popsection");
__asm( "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
"call __do_global_dtors_aux" "\n\t"
" nop" "\n\t"
".popsection");

View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $")
.section .ctors, "aw", @progbits
.align 8
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.quad 0
.section .dtors, "aw", @progbits
.align 8
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.quad 0
.section .eh_frame, "a", @progbits
.align 8
.quad 0
.section .jcr, "aw", @progbits
.align 8
.quad 0

View File

@@ -1,7 +1,32 @@
/* $NetBSD: dot_init.h,v 1.8 2008/05/10 15:31:04 martin Exp $ */
/* $NetBSD: crti.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */
/*
* Copyright (c) 2001 Matthew R. Green
* 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.
*/
/*-
* Copyright (c) 2004 Nick Hudson
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
@@ -34,36 +59,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
#include <machine/asm.h>
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
__asm ( \
".section "#sect",\"ax\",@progbits \n"\
".global "#entry_pt" \n"\
".proc \n"\
".callinfo frame=64, calls, save_rp, save_sp, entry_gr=3\n"\
".entry \n"\
#entry_pt": \n"\
" stw %rp, -20(%sp) \n"\
" copy %r3, %r1 \n"\
" copy %sp, %r3 \n"\
" stw,ma %r1, 64(%sp) \n"\
" /* fall thru */ \n"\
".exit \n"\
".procend \n"\
".previous")
RCSID("$NetBSD: crti.S,v 1.1 2013/07/11 06:57:15 martin Exp $")
#define MD_SECTION_EPILOGUE(sect) \
__asm ( \
".section "#sect",\"ax\",@progbits \n"\
" ldw -20(%r3) ,%rp \n"\
" ldo 64(%r3), %sp \n"\
" ldw,mb -64(%sp), %r3 \n"\
" bv,n %r0(%rp) \n"\
".previous")
#include "sysident.S"
#define MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, _init)
#define MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, _fini)
.section ".init", "ax", @progbits
.align 4
.globl _init
_init:
save %sp, -176, %sp
#define MD_INIT_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.init)
#define MD_FINI_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.fini)
.section ".fini", "ax", @progbits
.align 4
.globl _fini
_fini:
save %sp, -176, %sp

View File

@@ -1,4 +1,30 @@
/* $NetBSD: dot_init.h,v 1.9 2012/08/05 01:44:43 matt Exp $ */
/* $NetBSD: crtn.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */
/*
* Copyright (c) 2001 Matthew R. Green
* 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.
*/
/*-
* Copyright (c) 2001 Ross Harvey
@@ -33,29 +59,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
#include <machine/asm.h>
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
__asm ( \
".section "#sect",\"ax\",%progbits \n"\
".global "#entry_pt" \n"\
" .align 0 \n"\
#entry_pt": \n"\
"mov ip, sp \n"\
"stmfd sp!, {fp, ip, lr, pc} \n"\
"sub fp, ip, #4 \n"\
" /* fall thru */ \n"\
".previous")
RCSID("$NetBSD: crtn.S,v 1.1 2013/07/11 06:57:15 martin Exp $")
#define MD_SECTION_EPILOGUE(sect) \
__asm ( \
".section "#sect",\"ax\",%progbits \n"\
"ldmea fp, {fp, sp, pc} \n"\
".previous")
.section ".init", "ax", @progbits
.align 4
ret
restore
#define MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, _init)
#define MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, _fini)
#define MD_INIT_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.init)
#define MD_FINI_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.fini)
.section ".fini", "ax", @progbits
.align 4
ret
restore

View File

@@ -1,5 +1,3 @@
# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:34 joerg Exp $
CPPFLAGS+= -DELFSIZE=32
# $NetBSD: Makefile.inc,v 1.3 2013/06/25 00:30:07 matt Exp $
CPPFLAGS+= -I${ARCHDIR}

View File

@@ -1,10 +1,12 @@
/* $NetBSD: crt0.S,v 1.2 2011/07/02 20:14:10 matt Exp $ */
/* $NetBSD: crt0.S,v 1.3 2013/06/21 15:54:08 matt Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
* Copyright (c) 1995 Christopher G. Demetriou
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,37 +15,28 @@
* 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
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*
* 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.
*/
#include <machine/asm.h>
#include <vax/asm.h>
RCSID("$NetBSD: crt0.S,v 1.2 2011/07/02 20:14:10 matt Exp $")
RCSID("$NetBSD: crt0.S,v 1.3 2013/06/21 15:54:08 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
.word 0x0101
pushl %r9 /* ps_strings */
pushl %r8 /* obj */
_ENTRY(__start, 0x0101)
movq %r8,-(%sp) /* ps_strings / obj */
pushl %r7 /* cleanup */
calls $3,___start
END(__start)

178
lib/csu/arch/vax/crtbegin.S Normal file
View File

@@ -0,0 +1,178 @@
/* $NetBSD: crtbegin.S,v 1.6 2013/07/10 23:30:45 matt Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <vax/asm.h>
RCSID("$NetBSD: crtbegin.S,v 1.6 2013/07/10 23:30:45 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 2
__CTOR_LIST__: /* symbol is not used */
.long -1
.section .dtors, "aw", @progbits
.p2align 2
__DTOR_LIST__:
.long -1
.section .eh_frame, "a", @progbits
.p2align 2
__EH_FRAME_LIST__:
.section .jcr, "aw", @progbits
.p2align 2
__JCR_LIST__:
.section .data.rel, "aw", @progbits
.p2align 2
.type __dso_handle, @object
.size __dso_handle, 4
.globl __dso_handle
.hidden __dso_handle
__dso_handle:
#ifdef SHARED
.long __dso_handle
#else
.long 0
#endif
.local __dwarf_eh_object
.comm __dwarf_eh_object,32
.local __initialized
.comm __initialized,1
.local __finished
.comm __finished,1
.text
/*
* All variables are local to this DSO so we can skip using GOT references
* and instead use PCREL references to access them. We do this regardless
* of being PIC since it isn't any additional overhead to do so.
*
* We don't setup a TOC since all of ours calls are indirect so it isn't
* needed.
*/
_ENTRY(__do_global_dtors_aux, 0x0100) /* save r8 */
tstb __finished /* done this already? */
bneq 4f
movb $1, __finished /* mark it as done */
#ifdef SHARED
/*
* if (__cxa_finalize)
* __cxa_finalize(&__dso_handle);
*/
movab __cxa_finalize, %r0
beql 1f
pushal __dso_handle
calls $0, (%r0)
1:
#endif /* SHARED */
/*
* We use load with postincrement to advance the pointer along.
* We know the list ends with 0. If we load one, we must be done.
*/
moval __DTOR_LIST__+4, %r8 /* skip first entry */
2: movl (%r8)+, %r0 /* r0 = *r8++; */
beql 3f
calls $0, (%r0)
brb 2b
3:
#ifdef SHARED
/*
* if (__deregister_frame_info)
* __deregister_frame_info(&__EH_FRAME_LIST__[0]);
*/
moval __deregister_frame_info, %r0
beql 4f
pushal __EH_FRAME_LIST__
calls $0, (%r0)
#endif /* SHARED */
4: ret
END(__do_global_dtors_aux)
.weak __deregister_frame_info
.weak __cxa_finalize
.weak __register_frame_info
.weak _Jv_RegisterClasses
_ENTRY(__do_global_ctors_aux, 0x0800)
tstb __initialized
bneq 4f
movb $1, __initialized
/*
* if (__register_frame_info)
* __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
*/
movab __register_frame_info, %r0
beql 1f
pushal __dwarf_eh_object
pushal __EH_FRAME_LIST__
calls $0, (%r0)
1:
/*
* if (_Jv_RegisterClasses && __JCR_LIST__[0])
* _Jv_RegisterClasses(&__JCR_LIST__[0]);
*/
movab _Jv_RegisterClasses, %r0
beql 2f
pushal __JCR_LIST__
calls $0, (%r0)
2:
/*
* Get the end of the CTOR list. The first entry is -1 so if we
* load a negative address, we know we are done.
*/
moval __CTOR_LIST_END__, %r8 /* get end of list */
3: movl -(%r8), %r0 /* get function pointer with predec */
blss 4f /* negative? done. */
calls $0, (%r0) /* call it */
brb 3b /* get next one */
4: ret
END(__do_global_ctors_aux)
.hidden _C_LABEL(__CTOR_LIST_END__)
.section .init, "ax", @progbits
calls $0, __do_global_ctors_aux
.section .fini, "ax", @progbits
calls $0, __do_global_dtors_aux

View File

@@ -0,0 +1,36 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
__asm( ".pushsection .init, \"ax\", @progbits" "\n\t"
"calls $0, __do_global_ctors_aux" "\n\t"
".popsection" "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
"calls $0, __do_global_dtors_aux" "\n\t"
".popsection"
);

55
lib/csu/arch/vax/crtend.S Normal file
View File

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.2 2013/06/25 00:30:07 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <vax/asm.h>
RCSID("$NetBSD: crtend.S,v 1.2 2013/06/25 00:30:07 matt Exp $")
.section .ctors, "aw", @progbits
.p2align 2
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.long 0
.section .dtors, "aw", @progbits
.p2align 2
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits
.p2align 2
.space 4
.section .jcr, "aw", @progbits
.p2align 2
.space 4

View File

@@ -1,8 +0,0 @@
# $NetBSD: Makefile,v 1.4 2006/05/19 19:11:12 christos Exp $
CPPFLAGS+= -I${.CURDIR}
# Temporary hack to work around ld problems when linking Thumb applications
# where the linker does not correctly insert an interworking veneer.
CFLAGS+=-mlong-calls
.include "${.CURDIR}/../common_elf/Makefile.inc"

View File

@@ -1,111 +0,0 @@
/* $NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
* Copyright (C) 1995 Wolfgang Solfrank.
* Copyright (C) 1995 TooLs GmbH.
* 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 TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 <sys/param.h>
#include <machine/asm.h>
#include <stdlib.h>
#include "common.h"
extern void _start(void);
void ___start(int, char *[], char *[], struct ps_strings *,
const Obj_Entry *, void (*)(void));
__asm(" .text \n"
" .align 0 \n"
" .globl _start \n"
" .globl __start \n"
"_start: \n"
"__start: \n"
" mov r5, r2 /* cleanup */ \n"
" mov r4, r1 /* obj_main */ \n"
" mov r3, r0 /* ps_strings */ \n"
" /* Get argc, argv, and envp from stack */ \n"
" ldr r0, [sp, #0x0000] \n"
" add r1, sp, #0x0004 \n"
" add r2, r1, r0, lsl #2 \n"
" add r2, r2, #0x0004 \n"
"\n"
" /* Ensure the stack is properly aligned before calling C code. */\n"
" bic sp, sp, #" ___STRING(STACK_ALIGNBYTES) "\n"
" sub sp, sp, #8 \n"
" str r5, [sp, #4] \n"
" str r4, [sp, #0] \n"
"\n"
" b " ___STRING(_C_LABEL(___start)) " ");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $");
#endif /* LIBC_SCCS and not lint */
void
___start(int argc, char **argv, char **envp, struct ps_strings *ps_strings,
const Obj_Entry *obj, void (*cleanup)(void))
{
char *ap;
environ = envp;
__ps_strings = ps_strings;
if ((ap = argv[0])) {
if ((__progname = _strrchr(ap, '/')) == NULL)
__progname = ap;
else
++__progname;
}
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&rtld_DYNAMIC)
_rtld_setup(cleanup, obj);
#endif /* DYNAMIC */
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
#endif /* MCRT0 */
atexit(_fini);
_init();
__asm("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(argc, argv, envp));
}
#include "common.c"

View File

@@ -1,33 +1,62 @@
# $NetBSD: Makefile.inc,v 1.7 2012/03/25 06:55:19 joerg Exp $
# $NetBSD: Makefile.inc,v 1.23 2013/11/17 11:16:09 martin Exp $
.include <bsd.own.mk>
# XXX: FIXME: This is defined in bsd.lib.mk
PICFLAGS ?= -fPIC
COMMON_DIR:= ${.CURDIR}/common
.PATH: ${COMMON_DIR}
CPPFLAGS+= -I${NETBSDSRCDIR}/libexec/ld.elf_so -I${COMMON_DIR} -I.
OBJS+= crt0.o gcrt0.o crti.o crtn.o
OBJS+= crtbegin.o crtbeginS.o crtend.o
OBJS+= crtbegin.o crtend.o
# BJG - for backwards compatability with minix gcc
# which links with crt1.o instead of crt0.o
SYMLINKS+= crt0.o ${LIBDIR}/crt1.o
.if ${MKPIC} == "yes"
OBJS+= crtbeginS.o
CFLAGS.crtbegin.c+= -fPIE
.endif
.if ${MACHINE_ARCH} == "alpha"
OBJS+= crtfm.o
.endif
.if ${CSU_MACHINE_ARCH} == "sparc64"
# create helper objects for the compiler to mark compiler memory models
.for m in medlow medmid medany
sparc_mc${m}.o: compident.S sysident_assym.h
${CC} ${ASFLAGS} -I. -DCONTENT=\"${m}\\0\\0\" -DCONTENTLENGTH=8 -c \
-o $@ ${COMMON_DIR}/compident.S
.endfor
OBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o
.endif
realall: ${OBJS}
.if exists(${ARCHDIR}/crtbegin.S)
crtbegin.o: crtbegin.S
${_MKTARGET_COMPILE}
${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
.else
crtbegin.o: crtbegin.c crtbegin.h
${_MKTARGET_COMPILE}
${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
.endif
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
.if ${MKSTRIPIDENT} != "no"
${OBJCOPY} -R .ident ${.TARGET}
.endif
.if exists(${ARCHDIR}/crtbegin.S)
crtbeginS.o: crtbegin.S
${_MKTARGET_COMPILE}
${COMPILE.S} -DPIC -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
${COMPILE.S} ${PICFLAGS} -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o
.else
crtbeginS.o: crtbegin.c crtbegin.h
${_MKTARGET_COMPILE}
${COMPILE.c} ${PICFLAGS} -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
.endif
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
.if ${MKSTRIPIDENT} != "no"
@@ -44,15 +73,15 @@ crtend.o: crtend.S
.endif
.if ${MKPIC} != "no"
PICFLAGS= -fPIC
MY_PICFLAGS= ${PICFLAGS}
.else
PICFLAGS=
MY_PICFLAGS=
.endif
crt0.o: crt0.S crt0-common.c
${_MKTARGET_COMPILE}
${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
${COMPILE.c} ${PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
${COMPILE.c} ${MY_PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
rm -f ${.TARGET}.S.o ${.TARGET}.c.o
.if ${MKSTRIPIDENT} != "no"
@@ -62,14 +91,24 @@ crt0.o: crt0.S crt0-common.c
gcrt0.o: crt0.S crt0-common.c
${_MKTARGET_COMPILE}
${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o
${COMPILE.c} ${PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
${COMPILE.c} ${MY_PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.S.o ${.TARGET}.c.o
rm -f ${.TARGET}.S.o ${.TARGET}.c.o
.if ${MKSTRIPIDENT} != "no"
${OBJCOPY} -R .ident ${.TARGET}
.endif
sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
.if ${MACHINE_ARCH} == "alpha"
# can't do this in Makefile.inc otherwise it will before realall:
crtfm.o: crtfm.c
${_MKTARGET_COMPILE}
${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
rm -f ${.TARGET}.o
.endif
GENASSYM_CONF= ${COMMON_DIR}/sysident_assym.cf
sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} ${NETBSDSRCDIR}/sys/sys/param.h
${_MKTARGET_CREATE}
cat ${COMMON_DIR}/sysident_assym.cf | \
${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
@@ -78,13 +117,16 @@ sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
CLEANFILES+= sysident_assym.h
crti.o: crti.S sysident_assym.h
crti.o: crti.S sysident_assym.h sysident.S
crtn.o: crtn.S
FILES=${OBJS}
FILESDIR=${LIBDIR}
CLEANFILES+=${OBJS}
.if ${MKPIC} == "yes"
SYMLINKS+= crtbegin.o ${LIBDIR}/crtbeginT.o
SYMLINKS+= crtend.o ${LIBDIR}/crtendS.o
.endif
.include <bsd.prog.mk>

View File

@@ -0,0 +1,65 @@
/* $NetBSD: compident.S,v 1.1 2013/11/14 12:19:34 martin Exp $ */
/*-
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Martin Husemann <martin@NetBSD.org>.
*
* 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 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.
*/
/*
* This file is used to generate a note describing the code model in use by
* the compiler on some architectures where this has consequences for the
* VA layout applied by the kernel. On sparc64 the topdown VA layout can
* only be enabled for processes compiled with -mcmodel=medany or greater,
* but not for processes without this note or -mcmodel=medlow.
*
* The note looks similar to the .note.netbsd.march note used (for example)
* on arm to note the ABI used by the process.
*
* [NOTE HEADER]
* long name size
* long content size
* long note type
*
* [NOTE DATUM]
* string code model (for sparc64: medlow, medmid, medany,
* the embedany model is never PIC, so not used here)
*
* The DATUM fields should be padded out such that their actual (not
* declared) sizes % 4 == 0.
*/
#include "sysident_assym.h"
.section ".note.netbsd.mcmodel", "a"
.p2align 2
.long ELF_NOTE_MCMODEL_NAMESZ
.long CONTENTLENGTH
.long ELF_NOTE_TYPE_MCMODEL_TAG
.ascii "NetBSD\0\0"
.ascii CONTENT

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $ */
/* $NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -36,15 +36,15 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $");
__RCSID("$NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $");
#include <sys/types.h>
#include <sys/exec.h>
#ifndef __minix
#if !defined(__minix)
#include <sys/syscall.h>
#else
#include <string.h>
#endif
#endif /* !defined(__minix) */
#include <machine/profile.h>
#include <stdlib.h>
#include <unistd.h>
@@ -83,11 +83,11 @@ char *__progname = empty_string;
__dead __dso_hidden void ___start(void (*)(void), const Obj_Entry *,
struct ps_strings *);
#ifndef __minix
#if !defined(__minix)
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
#else
#define write(fd, s, n) /* NO write() from here on minix */
#endif
#endif /* !defined(__minix) */
#define _FATAL(str) \
do { \
@@ -103,10 +103,26 @@ do { \
* Since we don't need .init or .fini sections, just code them in C
* to make life easier.
*/
static const fptr_t init_array_start[] __weak_reference(__init_array_start);
static const fptr_t init_array_end[] __weak_reference(__init_array_end);
static const fptr_t fini_array_start[] __weak_reference(__fini_array_start);
static const fptr_t fini_array_end[] __weak_reference(__fini_array_end);
__weakref_visible const fptr_t preinit_array_start[1]
__weak_reference(__preinit_array_start);
__weakref_visible const fptr_t preinit_array_end[1]
__weak_reference(__preinit_array_end);
__weakref_visible const fptr_t init_array_start[1]
__weak_reference(__init_array_start);
__weakref_visible const fptr_t init_array_end[1]
__weak_reference(__init_array_end);
__weakref_visible const fptr_t fini_array_start[1]
__weak_reference(__fini_array_start);
__weakref_visible const fptr_t fini_array_end[1]
__weak_reference(__fini_array_end);
static inline void
_preinit(void)
{
for (const fptr_t *f = preinit_array_start; f < preinit_array_end; f++) {
(*f)();
}
}
static inline void
_init(void)
@@ -160,6 +176,10 @@ ___start(void (*cleanup)(void), /* from shared loader */
_libc_init();
#ifdef HAVE_INITFINI_ARRAY
_preinit();
#endif
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&__eprol, (u_long)&__etext);

135
lib/csu/common/crtbegin.c Normal file
View File

@@ -0,0 +1,135 @@
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* 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 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.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: crtbegin.c,v 1.6 2013/11/29 23:00:48 joerg Exp $");
#include "crtbegin.h"
typedef void (*fptr_t)(void);
__dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr");
__weakref_visible void Jv_RegisterClasses(const fptr_t *)
__weak_reference(_Jv_RegisterClasses);
#if !defined(HAVE_INITFINI_ARRAY)
__dso_hidden const fptr_t __CTOR_LIST__[] __section(".ctors") = {
(fptr_t) -1,
};
__dso_hidden extern const fptr_t __CTOR_LIST_END__[];
#endif
#ifdef SHARED
__dso_hidden void *__dso_handle = &__dso_handle;
__weakref_visible void cxa_finalize(void *)
__weak_reference(__cxa_finalize);
#else
__dso_hidden void *__dso_handle;
#endif
#if !defined(__ARM_EABI__)
__dso_hidden
#if !defined(__mips__)
const
#endif
long __EH_FRAME_LIST__[0] __section(".eh_frame");
__weakref_visible void register_frame_info(const void *, const void *)
__weak_reference(__register_frame_info);
__weakref_visible void deregister_frame_info(const void *)
__weak_reference(__deregister_frame_info);
static long dwarf_eh_object[8];
#endif
static void __do_global_ctors_aux(void) __used;
static void __section(".text.startup")
__do_global_ctors_aux(void)
{
static unsigned char __initialized;
if (__initialized)
return;
__initialized = 1;
#if !defined(__ARM_EABI__)
if (register_frame_info)
register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object);
#endif
if (Jv_RegisterClasses && __JCR_LIST__[0] != 0)
Jv_RegisterClasses(__JCR_LIST__);
#if !defined(HAVE_INITFINI_ARRAY)
for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) {
(*(*--p))();
}
#endif
}
#if !defined(__ARM_EABI__) || defined(SHARED)
#if !defined(HAVE_INITFINI_ARRAY)
__dso_hidden const fptr_t __DTOR_LIST__[] __section(".dtors") = {
(fptr_t) -1,
};
__dso_hidden extern const fptr_t __DTOR_LIST_END__[];
#endif
static void __do_global_dtors_aux(void) __used;
static void __section(".text.exit")
__do_global_dtors_aux(void)
{
static unsigned char __finished;
if (__finished)
return;
__finished = 1;
#ifdef SHARED
if (cxa_finalize)
(*cxa_finalize)(__dso_handle);
#endif
#if !defined(HAVE_INITFINI_ARRAY)
for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) {
(*(*p++))();
}
#endif
#if !defined(__ARM_EABI__)
if (deregister_frame_info)
deregister_frame_info(__EH_FRAME_LIST__);
#endif
}
#endif /* !__ARM_EABI__ || SHARED */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: sysident.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: sysident.S,v 1.2 2013/09/10 16:45:33 matt Exp $ */
/*
* Copyright (c) 1997 Christopher G. Demetriou
@@ -58,25 +58,41 @@
#include "sysident_assym.h"
#ifdef __minix
.section .rodata
.ascii "$MINIX$\0"
#if defined(__minix)
.section ".note.minix.ident", "a"
.p2align 2
.long ELF_NOTE_MINIX_NAMESZ
.long ELF_NOTE_MINIX_DESCSZ
.long ELF_NOTE_TYPE_MINIX_TAG
.ascii "Minix\0\0\0" /* ELF_NOTE_NETBSD_NAME */
.long 300300000 /* Minix versiont as in "%d%03d%03d", MAJ-MIN-TEENY */
#else
.section ".note.netbsd.ident", "a"
.align 4
.p2align 2
.long ELF_NOTE_NETBSD_NAMESZ
.long ELF_NOTE_NETBSD_DESCSZ
.long ELF_NOTE_TYPE_NETBSD_TAG
.ascii "NetBSD\0\0" /* ELF_NOTE_NETBSD_NAME */
.long __NetBSD_Version__
#endif /* defined(__minix) */
.section ".note.netbsd.pax", "a"
.align 4
.p2align 2
.long ELF_NOTE_PAX_NAMESZ
.long ELF_NOTE_PAX_DESCSZ
.long ELF_NOTE_TYPE_PAX_TAG
.ascii "PaX\0" /* ELF_NOTE_PAX_NAME */
.long 0
#ifdef ELF_NOTE_MARCH_DESC
.section ".note.netbsd.march", "a"
.p2align 2
.long ELF_NOTE_MARCH_NAMESZ
.long ELF_NOTE_MARCH_DESCSZ
.long ELF_NOTE_TYPE_MARCH_TAG
.ascii "NetBSD\0\0"
.asciz ELF_NOTE_MARCH_DESC
#endif

View File

@@ -10,3 +10,18 @@ define ELF_NOTE_PAX_NAMESZ ELF_NOTE_PAX_NAMESZ
define ELF_NOTE_PAX_DESCSZ ELF_NOTE_PAX_DESCSZ
define ELF_NOTE_TYPE_PAX_TAG ELF_NOTE_TYPE_PAX_TAG
#define ELF_NOTE_PAX_NAME ELF_NOTE_PAX_NAME
ifdef ELF_NOTE_MARCH_DESC
define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_MARCH_NAMESZ
define ELF_NOTE_MARCH_DESCSZ sizeof(ELF_NOTE_MARCH_DESC)
define ELF_NOTE_TYPE_MARCH_TAG ELF_NOTE_TYPE_MARCH_TAG
#define ELF_NOTE_MARCH_NAME ELF_NOTE_MARCH_NAME
#define ELF_NOTE_MARCH_DESC ELF_NOTE_MARCH_DESC
endif
define ELF_NOTE_MCMODEL_NAMESZ ELF_NOTE_MCMODEL_NAMESZ
define ELF_NOTE_TYPE_MCMODEL_TAG ELF_NOTE_TYPE_MCMODEL_TAG
define ELF_NOTE_MINIX_NAMESZ ELF_NOTE_MINIX_NAMESZ
define ELF_NOTE_MINIX_DESCSZ ELF_NOTE_MINIX_DESCSZ
define ELF_NOTE_TYPE_MINIX_TAG ELF_NOTE_TYPE_MINIX_TAG

View File

@@ -36,9 +36,9 @@
#include <sys/types.h>
#include <sys/exec.h>
#ifndef __minix
#if !defined(__minix)
#include <sys/syscall.h>
#endif
#endif /* !defined(__minix) */
#include <stdlib.h>
#ifdef DYNAMIC

View File

@@ -1,4 +0,0 @@
# $NetBSD: Makefile,v 1.3 2006/05/19 19:11:12 christos Exp $
CPPFLAGS+= -I${.CURDIR}
.include "${.CURDIR}/../common_elf/Makefile.inc"

View File

@@ -1,139 +0,0 @@
/* $NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 2002 Matt Fredette
* Copyright (c) 1999 Klaus Klein
* 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
* 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.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include "common.h"
static void ___start(struct ps_strings *,
void (*cleanup)(void), const Obj_Entry *, int)
#ifdef __GNUC__
__attribute__((__used__))
#endif
;
__asm("\n"
" .text \n"
" .align 4 \n"
" .globl _start \n"
" .globl __start \n"
" .type _start,@function \n"
" .type __start,@function \n"
"_start: \n"
"__start: \n"
" .import _GLOBAL_OFFSET_TABLE_ \n"
"\n"
" bl L$lpc, %r27 \n"
" depi 0, 31, 2, %r27 \n"
"L$lpc: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8), %r27 \n"
" ldo R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%r1),%r27 \n"
" copy %r27, %r19 \n"
" b ___start \n"
" copy %r27, %arg3 \n");
static void
___start(struct ps_strings *ps_strings,
void (*cleanup)(void), /* from shared loader */
const Obj_Entry *obj, /* from shared loader */
int dp)
{
int argc;
char **argv;
int fini_plabel[2];
argc = ps_strings->ps_nargvstr;
argv = ps_strings->ps_argvstr;
environ = ps_strings->ps_envstr;
if ((__progname = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
if ((__progname = _strrchr(__progname, '/')) == NULL)
__progname = argv[0];
else
__progname++;
}
if (ps_strings != (struct ps_strings *)0)
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
#endif
/*
* Since crt0.o, crtbegin.o, and crtend.o are always
* compiled PIC, they must have %r19 set correctly on
* entry to any function they contain. However, when
* a program is linked statically, the linker does
* not fill a PLABEL relocation with a pointer to a
* true PLABEL, it just fills it with the offset of the
* function. This shows the linker's assumption that
* when linking statically, *all* of the code has *not*
* been compiled PIC. I guess to assume otherwise
* would be a performance hit, as you would end up
* with unnecessary PLABELs for function pointers.
*
* But here, passing the address of the PIC _fini to
* atexit, we must make sure that we pass a PLABEL.
*/
fini_plabel[0] = (int)_fini;
if (fini_plabel[0] & 2)
/* _fini is already a PLABEL. */
atexit(_fini);
else {
fini_plabel[1] = dp;
atexit((void (*)(void))(((int)fini_plabel) | 2));
}
_init();
exit(main(argc, argv, environ));
}
/*
* NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
*/
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"