Libraries updates and cleanup

* Updating common/lib
 * Updating lib/csu
 * Updating lib/libc
 * Updating libexec/ld.elf_so
 * Corrected test on __minix in featuretest to actually follow the
   meaning of the comment.
 * Cleaned up _REENTRANT-related defintions.
 * Disabled -D_REENTRANT for libfetch
 * Removing some unneeded __NBSD_LIBC defines and tests

Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
2012-11-15 12:06:41 +01:00
parent f6aac1c3b5
commit f14fb60209
1285 changed files with 44244 additions and 14308 deletions

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.24 2003/07/26 19:24:25 salo Exp $ */
/* $NetBSD: crt0.c,v 1.27 2012/03/22 13:02:15 he Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -40,11 +40,8 @@ void __start __P((char **, void (*cleanup) __P((void)), const Obj_Entry *,
struct ps_strings *));
void
__start(sp, cleanup, obj, ps_strings)
char **sp;
void (*cleanup) __P((void)); /* from shared loader */
const Obj_Entry *obj; /* from shared loader */
struct ps_strings *ps_strings;
__start(char **sp, void (*cleanup)(void),
const Obj_Entry *obj, struct ps_strings *ps_strings)
{
long argc;
char **argv, *namep;
@@ -65,10 +62,12 @@ __start(sp, cleanup, obj, ps_strings)
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -84,7 +83,7 @@ __start(sp, cleanup, obj, ps_strings)
* 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.24 2003/07/26 19:24:25 salo Exp $");
__RCSID("$NetBSD: crt0.c,v 1.27 2012/03/22 13:02:15 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,5 +1,3 @@
# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:33 joerg Exp $
# $NetBSD: Makefile.inc,v 1.2 2012/09/16 13:46:49 skrll Exp $
CPPFLAGS+= -DELFSIZE=32

View File

@@ -1,11 +1,12 @@
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
* Copyright (C) 1995 Wolfgang Solfrank.
* Copyright (C) 1995 TooLs GmbH.
/*-
* 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:
@@ -14,43 +15,41 @@
* 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.
* 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 2010/08/07 18:01:33 joerg Exp $")
#include <arm/asm.h>
RCSID("$NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
mov r5, r2 /* cleanup */
mov r4, r1 /* obj_main */
mov r3, r0 /* ps_strings */
/* Get argc, argv, and envp from stack */
ldr r0, [sp, #0x0000]
add r1, sp, #0x0004
add r2, r1, r0, lsl #2
add r2, r2, #0x0004
/*
* We need to swap ps_strings and cleanup
*/
mov ip, r0 /* ps_strings -> tmp */
mov r0, r2 /* cleanup -> ps_strings */
mov r2, ip /* tmp -> ps_strings */
/* Ensure the stack is properly aligned before calling C code. */
bic sp, sp, #7
sub sp, sp, #8
str r5, [sp, #4]
str r4, [sp, #0]
/*
* void ___start(void (*cleanup)(void),
* const Obj_Entry *obj,
* struct ps_strings *ps_strings);
*/
b ___start

293
lib/csu/arch/arm/crtbegin.S Normal file
View File

@@ -0,0 +1,293 @@
/* $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

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

@@ -0,0 +1,55 @@
/* $NetBSD: crtend.S,v 1.2 2012/08/11 07:26:25 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: crtend.S,v 1.2 2012/08/11 07:26:25 matt Exp $")
.section .ctors, "aw", %progbits
.p2align 2
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.space 4
.section .dtors, "aw", %progbits
.p2align 2
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.space 4
.section .eh_frame, "a", %progbits
.p2align 2
.space 4
.section .jcr, "aw", %progbits
.p2align 2
.space 4

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -35,21 +35,23 @@
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
RCSID("$NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.section ".init", "ax", %progbits
.align 0
.globl _init
.type _init,%function
_init:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
.section ".fini", "ax", @progbits
.section ".fini", "ax", %progbits
.align 0
.globl _fini
.type _fini,%function
_fini:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -35,10 +35,10 @@
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
RCSID("$NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $")
.section ".init", "ax", @progbits
.section ".init", "ax", %progbits
ldmea fp, {fp, sp, pc}
.section ".fini", "ax", @progbits
.section ".fini", "ax", %progbits
ldmea fp, {fp, sp, pc}

View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2012/08/13 02:49:04 matt Exp $
CPPFLAGS+= -DELFSIZE=32
CPPFLAGS+= -DHAVE_INITFINI_ARRAY

55
lib/csu/arch/earm/crt0.S Normal file
View File

@@ -0,0 +1,55 @@
/* $NetBSD: crt0.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: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
/*
* We need to swap ps_strings and cleanup
*/
mov ip, r0 /* ps_strings -> tmp */
mov r0, r2 /* cleanup -> ps_strings */
mov r2, ip /* tmp -> ps_strings */
/* Ensure the stack is properly aligned before calling C code. */
bic sp, sp, #7
/*
* void ___start(void (*cleanup)(void),
* const Obj_Entry *obj,
* struct ps_strings *ps_strings);
*/
b ___start

View File

@@ -0,0 +1,216 @@
/* $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,54 @@
/* $NetBSD: crtend.S,v 1.1 2012/08/13 02:49:04 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 <arm/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
.fpu softvfp
.eabi_attribute 18, 4 /* sizeof(wchar_t) */
.eabi_attribute 23, 0 /* doesn't use floating point */
.eabi_attribute 24, 1 /* 8 byte alignment permitted */
.eabi_attribute 25, 1 /* preserves 8-byte alignment */
.eabi_attribute 26, 2 /* enums are 32-bits */
.section .eh_frame, "a", %progbits
.p2align 2
.global __EH_FRAME_END__
.hidden __EH_FRAME_END__
__EH_FRAME_END__:
.space 4
.section .jcr, "aw", %progbits
.p2align 2
.global __JCR_END__
.hidden __JCR_END__
__JCR_END__:
.space 4

41
lib/csu/arch/earm/crti.S Normal file
View File

@@ -0,0 +1,41 @@
/* $NetBSD: crti.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: crti.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
#include "sysident.S"
/*
* Since ARM EABI uses .init_array/.fini_array,
* there is no need for .init/.fini
*/

3
lib/csu/arch/earm/crtn.S Normal file
View File

@@ -0,0 +1,3 @@
/* $NetBSD: crtn.S,v 1.1 2012/08/13 02:49:04 matt Exp $ */
/* no need for anything here since ARM EABI uses .init_array/.fini_array */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -37,17 +37,21 @@
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
RCSID("$NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $")
.hidden ___start
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
pushl %ebx
pushl %ecx
pushl %edx
movl 12(%esp),%eax
leal 16(%esp),%edx
leal 20(%esp,%eax,4),%ecx
pushl %ecx
pushl %edx
pushl %eax
#ifdef __minix
movl 12(%esp),%eax
leal 16(%esp),%edx
leal 20(%esp,%eax,4),%ecx
pushl %ecx
pushl %edx
pushl %eax
#endif /* __minix */
call ___start

View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile.inc,v 1.1 2011/02/08 02:02:25 matt Exp $
CPPFLAGS+= -DELFSIZE=32

View File

@@ -0,0 +1,53 @@
/*-
* 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: crt0.S,v 1.4 2011/07/02 20:16:09 matt Exp $")
STRONG_ALIAS(_start,__start)
.hidden ___start
.weak _SDA_BASE_
ENTRY_NOPROFILE(__start)
bcl 20,31,1f
1:
mflr %r11
/* SVR4 ABI says small data is in r13 */
addis %r13,%r11,_SDA_BASE_-1b@ha
addi %r13,%r13,_SDA_BASE_-1b@l
mr %r3,%r7 /* cleanup */
mr %r4,%r6 /* obj */
mr %r5,%r8 /* ps_strings */
b ___start
END(__start)

View File

@@ -0,0 +1,268 @@
/* $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,52 @@
/* $NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 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: crtend.S,v 1.1 2011/02/08 02:02:25 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
.long 0
.section .eh_frame, "a", @progbits
.p2align 2
.long 0
.section .jcr, "aw", @progbits
.p2align 2
.long 0

View File

@@ -0,0 +1,50 @@
/* $NetBSD: crti.S,v 1.1 2011/02/08 02:02:25 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: crti.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 2; .globl _init; .type _init,@function
_init:
mflr %r0
stw %r0, (1*SZREG)(%r1)
stwu %r1, -(4*SZREG)(%r1)
.section ".fini", "ax", @progbits
.align 2; .globl _fini; .type _fini,@function
_fini:
mflr %r0
stw %r0, (1*SZREG)(%r1)
stwu %r1, -(4*SZREG)(%r1)

View File

@@ -0,0 +1,44 @@
/*-
* 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: crtn.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
.section ".init", "ax", @progbits
addi %r1, %r1, (4*SZREG)
lwz %r0, (1*SZREG)(%r1)
mtlr %r0
blr
.section ".fini", "ax", @progbits
addi %r1, %r1, (4*SZREG)
lwz %r0, (1*SZREG)(%r1)
mtlr %r0
blr

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.4 2012/01/31 20:17:57 uwe Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -37,11 +37,23 @@
#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.4 2012/01/31 20:17:57 uwe Exp $")
STRONG_ALIAS(_start,__start)
/*
* Kernel setregs() passes arguments for the 6-argument version of
* ___start (but with 5th and 6th in registers, to avoid copyout).
* Since we now use 3-argument version of ___start - that obtains
* argc, argv and environ from ps_strings - move its arguments to
* proper registers.
*/
_ENTRY(__start)
mov.l r9,@-r15
bra ___start
mov.l r8,@-r15
mov.l .L___start, r0
mov r7, r4 ! void (*cleanup)(void)
mov r8, r5 ! const Obj_Entry *obj
jmp @r0
mov r9, r6 ! struct ps_strings *ps_strings
.p2align 2
.L___start: .long _C_LABEL(___start)

366
lib/csu/arch/sh3/crtbegin.S Normal file
View File

@@ -0,0 +1,366 @@
/* $NetBSD: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe Exp $ */
/*-
* Copyright (c) 2012 Valeriy E. Ushakov
* 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: crtbegin.S,v 1.2 2012/06/02 22:15:15 uwe 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 .data.rel, "aw", @progbits
.p2align 2
.globl __dso_handle
.hidden __dso_handle
.type __dso_handle, @object
.size __dso_handle, 4
__dso_handle:
#ifdef SHARED
.long __dso_handle
#else
.long 0
#endif
__dwarf_eh_object:
.zero 32
__initialized:
.zero 1
__finished:
.zero 1
.text
.weak __cxa_finalize
.weak __deregister_frame_info
.weak __register_frame_info
.weak _Jv_RegisterClasses
/*
* A bit of CPP syntactic sugar for accessing variables.
*
* For PIC we are obliged to use @(r0, r12) since r12 has the GOT
* address and only r0 can be used in @(r0, Rm) addressing mode, so we
* always load variable address to r0.
*/
#ifdef PIC
#define VAR_DATUM(var) var@GOTOFF
#define FUNC_DATUM(f) f@GOT
#define R0VAR (r0, r12)
#else
#define VAR_DATUM(var) var
#define FUNC_DATUM(f) f
#define R0VAR r0
#endif
__do_global_ctors_aux:
mov.l r8, @-sp
mov.l r9, @-sp
#ifdef PIC
mov.l r12, @-sp
mov.l .Lc_got, r12
mova .Lc_got, r0
add r0, r12
#endif
mov.l r14, @-sp
sts.l pr, @-sp
mov sp, r14
!! if (__initialized) return;
mov.l .Lc___initialized, r0
mov.b @R0VAR, r1
tst r1, r1
bf .Lc_return
!! __initialized = 1;
mov #1, r1
mov.b r1, @R0VAR
!! if (__register_frame_info)
!! __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
#ifdef PIC
mov.l .Lc___register_frame_info_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Lc___register_frame_info_done
mov.l .Lc___register_frame_info, r0
mov.l .Lc___EH_FRAME_LIST__, r4
mov.l .Lc___dwarf_eh_object, r5
add r12, r4
.Lc___register_frame_info_call:
CALL r0
add r12, r5
#else /* !PIC */
mov.l .Lc___register_frame_info, r0
tst r0, r0
bt .Lc___register_frame_info_done
mov.l .Lc___EH_FRAME_LIST__, r4
mov.l .Lc___dwarf_eh_object, r5
CALL r0
nop
#endif
.Lc___register_frame_info_done:
!! if (_Jv_RegisterClasses && __JCR_LIST__[0])
!! _Jv_RegisterClasses(&__JCR_LIST__[0]);
#ifdef PIC
mov.l .Lc__Jv_RegisterClasses_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Lc__Jv_RegisterClasses_done
mov.l .Lc___JCR_LIST__, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Lc__Jv_RegisterClasses_done
mov.l .Lc__Jv_RegisterClasses, r2
mov r0, r4
.Lc__Jv_RegisterClasses_call:
CALL r2
add r12, r4
#else /* !PIC */
mov.l .Lc__Jv_RegisterClasses, r2
tst r2, r2
bt .Lc__Jv_RegisterClasses_done
mov.l .Lc___JCR_LIST__, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Lc__Jv_RegisterClasses_done
mov r0, r4
.Lc__Jv_RegisterClasses_call:
CALL r2
add r12, r4
#endif
.Lc__Jv_RegisterClasses_done:
!! call all constructors on __CTOR_LIST__ in reverse order
mov.l .Lc___CTOR_LIST_END__, r8
#ifdef PIC
add r12, r8
#endif
add #-4, r8
mov.l @r8, r9
not r9, r0 ! sentinel at __CTOR_LIST__[0] is -1
.Lc_ctor_list_loop:
tst r0, r0
bt.s .Lc_ctor_list_done
add #-4, r8
jsr @r9
mov.l @r8, r9
bra .Lc_ctor_list_loop
not r9, r0
.Lc_ctor_list_done:
.Lc_return:
mov r14, sp
lds.l @sp+, pr
mov.l @sp+, r14
#ifdef PIC
mov.l @sp+, r12
#endif
mov.l @sp+, r9
rts
mov.l @sp+, r8
.p2align 2
.Lc_got:
PIC_GOT_DATUM
.Lc___initialized:
.long VAR_DATUM(__initialized)
#ifdef PIC
.Lc___register_frame_info_GOT:
.long __register_frame_info@GOT
#endif
.Lc___register_frame_info:
CALL_DATUM(__register_frame_info, .Lc___register_frame_info_call)
.Lc___EH_FRAME_LIST__:
.long VAR_DATUM(__EH_FRAME_LIST__)
.Lc___dwarf_eh_object:
.long VAR_DATUM(__dwarf_eh_object)
#ifdef PIC
.Lc__Jv_RegisterClasses_GOT:
.long _Jv_RegisterClasses@GOT
#endif
.Lc__Jv_RegisterClasses:
CALL_DATUM(_Jv_RegisterClasses, .Lc__Jv_RegisterClasses_call)
.Lc___JCR_LIST__:
.long VAR_DATUM(__JCR_LIST__)
.Lc___CTOR_LIST_END__:
.long VAR_DATUM(__CTOR_LIST_END__)
__do_global_dtors_aux:
mov.l r8, @-sp
mov.l r9, @-sp
#ifdef PIC
mov.l r12, @-sp
mov.l .Ld_got, r12
mova .Ld_got, r0
add r0, r12
#endif
mov.l r14, @-sp
sts.l pr, @-sp
mov sp, r14
!! if (__finished) return;
mov.l .Ld___finished, r0
mov.b @R0VAR, r1
tst r1, r1
bf .Ld_return
!! __finished = 1;
mov #1, r1
mov.b r1, @R0VAR
#ifdef SHARED /* implies PIC */
!! if (__cxa_finalize)
!! __cxa_finalize(&__dso_handle);
mov.l .Ld___cxa_finalize_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Ld___cxa_finalize_done
mov.l .Ld___cxa_finalize, r0
mov.l .Ld___dso_handle, r4
.Ld___cxa_finalize_call:
CALL r0
add r12, r4
.Ld___cxa_finalize_done:
#endif /* SHARED */
!! call all destructors on __DTOR_LIST__
mov.l .Ld___DTOR_LIST__, r8
#ifdef PIC
add r12, r8
#endif
add #4, r8 ! skip first entry that we know to be -1
mov.l @r8+, r9
tst r9, r9
.Ld_dtor_list_loop:
bt .Ld_dtor_list_done
jsr @r9
mov.l @r8+, r9
bra .Ld_dtor_list_loop
tst r9, r9
.Ld_dtor_list_done:
!! if (__deregister_frame_info)
!! __deregister_frame_info(&__EH_FRAME_LIST__[0]);
#ifdef PIC
mov.l .Ld___deregister_frame_info_GOT, r0
mov.l @R0VAR, r1
tst r1, r1
bt .Ld___deregister_frame_info_done
mov.l .Ld___deregister_frame_info, r0
mov.l .Ld___EH_FRAME_LIST__, r4
.Ld___deregister_frame_info_call:
CALL r0
add r12, r4
#else /* !PIC */
mov.l .Ld___deregister_frame_info, r0
tst r0, r0
bt .Ld___deregister_frame_info_done
mov.l .Ld___EH_FRAME_LIST__, r4
CALL r0
nop
#endif
.Ld___deregister_frame_info_done:
.Ld_return:
mov r14, sp
lds.l @sp+, pr
mov.l @sp+, r14
#ifdef PIC
mov.l @sp+, r12
#endif
mov.l @sp+, r9
rts
mov.l @sp+, r8
.p2align 2
.Ld_got:
PIC_GOT_DATUM
.Ld___finished:
.long VAR_DATUM(__finished)
#ifdef SHARED /* implies PIC */
.Ld___cxa_finalize_GOT:
.long __cxa_finalize@GOT
.Ld___cxa_finalize:
CALL_DATUM(__cxa_finalize, .Ld___cxa_finalize_call)
.Ld___dso_handle:
.long VAR_DATUM(__dso_handle)
#endif
.Ld___DTOR_LIST__:
.long VAR_DATUM(__DTOR_LIST__)
#ifdef PIC
.Ld___deregister_frame_info_GOT:
.long __deregister_frame_info@GOT
#endif
.Ld___deregister_frame_info:
CALL_DATUM(__deregister_frame_info, .Ld___deregister_frame_info_call)
.Ld___EH_FRAME_LIST__:
.long VAR_DATUM(__EH_FRAME_LIST__)
#define _CALL_INIT_FINI_FUNCTION(func) \
mov.l 1f, r1; \
mova 2f, r0; \
0: braf r1; /* NB: branch, not call ... */ \
lds r0, pr; /* skip the following .long when returning */ \
.p2align 2; \
1: .long func - (0b+4); \
2: ;
.section .init, "ax", @progbits
_CALL_INIT_FINI_FUNCTION(__do_global_ctors_aux)
.section .fini, "ax", @progbits
_CALL_INIT_FINI_FUNCTION(__do_global_dtors_aux)

52
lib/csu/arch/sh3/crtend.S Normal file
View File

@@ -0,0 +1,52 @@
/* $NetBSD: crtend.S,v 1.2 2012/01/31 20:12:47 uwe 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.2 2012/01/31 20:12:47 uwe 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
.long 0
.section .eh_frame, "a", @progbits
.p2align 2
.long 0
.section .jcr, "aw", @progbits
.p2align 2
.long 0

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/* $NetBSD: crti.S,v 1.3 2012/01/31 20:12:47 uwe Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -35,12 +35,18 @@
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
RCSID("$NetBSD: crti.S,v 1.3 2012/01/31 20:12:47 uwe Exp $")
#include "sysident.S"
/*
* Provide function prologues for the code in .init and .fini sections.
* Corresponding epilogues are in crtn.S
*/
.section ".init", "ax", @progbits
.align 4
.p2align 2
.globl _init
_init:
mov.l r14, @-sp
@@ -48,7 +54,7 @@ _init:
mov sp, r14
.section ".fini", "ax", @progbits
.align 4
.p2align 2
.globl _fini
_fini:
mov.l r14, @-sp

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/* $NetBSD: crtn.S,v 1.2 2012/01/28 12:45:43 uwe Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -35,7 +35,13 @@
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
RCSID("$NetBSD: crtn.S,v 1.2 2012/01/28 12:45:43 uwe Exp $")
/*
* Provide function epilogues for the code in .init and .fini sections.
* Corresponding prologues are in crti.S
*/
.section ".init", "ax", @progbits
mov r14, sp

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 2011/07/02 20:14:10 matt Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
@@ -37,7 +37,7 @@
#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 2011/07/02 20:14:10 matt Exp $")
STRONG_ALIAS(_start,__start)
@@ -46,8 +46,4 @@ _ENTRY(__start)
pushl %r9 /* ps_strings */
pushl %r8 /* obj */
pushl %r7 /* cleanup */
movl (%r6),%r0 /* argc */
pushal 8(%r6)[%r0] /* envp = &argv[argc + 1] */
pushal 4(%r6) /* argv */
pushl %r0 /* argc */
calls $6,___start
calls $3,___start

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.3 2011/07/01 02:59:05 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -35,18 +35,15 @@
#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.3 2011/07/01 02:59:05 joerg Exp $")
STRONG_ALIAS(_start,__start)
.hidden ___start
_ENTRY(__start)
movq %rbx,%r9
movq %rcx,%r8
movq %rdx,%rcx
movq (%rsp),%rdi
leaq 16(%rsp,%rdi,8),%rdx
leaq 8(%rsp),%rsi
subq $8,%rsp
andq $~15,%rsp
addq $8,%rsp
andq $~15,%rsp
subq $8,%rsp
movq %rdx, %rdi
movq %rcx, %rsi
movq %rbx, %rdx
jmp ___start

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.7 2008/06/21 00:52:52 gmcgarry Exp $ */
/* $NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
@@ -60,7 +60,7 @@ __asm(" .text \n"
" add r2, r2, #0x0004 \n"
"\n"
" /* Ensure the stack is properly aligned before calling C code. */\n"
" bic sp, sp, #" ___STRING(STACKALIGNBYTES) " \n"
" bic sp, sp, #" ___STRING(STACK_ALIGNBYTES) "\n"
" sub sp, sp, #8 \n"
" str r5, [sp, #4] \n"
" str r4, [sp, #0] \n"
@@ -68,7 +68,7 @@ __asm(" .text \n"
" b " ___STRING(_C_LABEL(___start)) " ");
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.7 2008/06/21 00:52:52 gmcgarry Exp $");
__RCSID("$NetBSD: crt0.c,v 1.10 2012/01/25 13:29:58 he Exp $");
#endif /* LIBC_SCCS and not lint */
void
@@ -89,10 +89,12 @@ ___start(int argc, char **argv, char **envp, struct ps_strings *ps_strings,
#ifdef DYNAMIC
/* ld(1) convention: if DYNAMIC = 0 then statically linked */
if (&_DYNAMIC)
if (&rtld_DYNAMIC)
_rtld_setup(cleanup, obj);
#endif /* DYNAMIC */
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: dot_init.h,v 1.6 2008/05/10 15:31:03 martin Exp $ */
/* $NetBSD: dot_init.h,v 1.9 2012/08/05 01:44:43 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey

View File

@@ -82,6 +82,5 @@ FILESDIR=${LIBDIR}
CLEANFILES+=${OBJS}
SYMLINKS+= crtbegin.o ${LIBDIR}/crtbeginT.o
SYMLINKS+= crtend.o ${LIBDIR}/crtendS.o
SYMLINKS+= crt0.o ${LIBDIR}/crt1.o
.include <bsd.prog.mk>

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0-common.c,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/* $NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -36,9 +36,10 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: crt0-common.c,v 1.1 2010/08/07 18:01:33 joerg Exp $");
__RCSID("$NetBSD: crt0-common.c,v 1.9 2012/08/13 02:15:35 matt Exp $");
#include <sys/types.h>
#include <sys/exec.h>
#ifndef __minix
#include <sys/syscall.h>
#endif
@@ -50,8 +51,11 @@ __RCSID("$NetBSD: crt0-common.c,v 1.1 2010/08/07 18:01:33 joerg Exp $");
extern int main(int, char **, char **);
#ifndef HAVE_INITFINI_ARRAY
extern void _init(void);
extern void _fini(void);
#endif
extern void _libc_init(void);
/*
* Arrange for _DYNAMIC to be weak and undefined (and therefore to show up
@@ -60,13 +64,7 @@ extern void _fini(void);
* shared libs present, things will still work.
*/
#if __GNUC_PREREQ__(4,2)
static int rtld_DYNAMIC __attribute__((__weakref__, __alias__("_DYNAMIC")));
#define DYNAMIC_SYM rtld_DYNAMIC
#else
extern int _DYNAMIC __weak_reference(_DYNAMIC);
#define DYNAMIC_SYM _DYNAMIC
#endif
__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#ifdef MCRT0
extern void monstartup(u_long, u_long);
@@ -80,12 +78,15 @@ struct ps_strings *__ps_strings = 0;
static char empty_string[] = "";
char *__progname = empty_string;
void ___start(int, char **, char **, void (*)(void),
const Obj_Entry *, struct ps_strings *);
#ifndef __minix
__dead __dso_hidden void ___start(void (*)(void), const Obj_Entry *,
struct ps_strings *);
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
#else
__dead __dso_hidden void ___start(int, char **, char **, void (*)(void),
const Obj_Entry *, struct ps_strings *);
#define write(fd, s, n) /* NO write() from here on minix */
#endif
@@ -95,18 +96,69 @@ do { \
_exit(1); \
} while (0)
#ifdef HAVE_INITFINI_ARRAY
/*
* If we are using INIT_ARRAY/FINI_ARRAY and we are linked statically,
* we have to process these instead of relying on RTLD to do it for us.
*
* 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);
static inline void
_init(void)
{
for (const fptr_t *f = init_array_start; f < init_array_end; f++) {
(*f)();
}
}
static void
_fini(void)
{
for (const fptr_t *f = fini_array_start; f < fini_array_end; f++) {
(*f)();
}
}
#endif /* HAVE_INITFINI_ARRAY */
void
#ifdef __minix
___start(int argc, char **argv, char **envp,
void (*cleanup)(void), /* from shared loader */
void (*cleanup)(void), /* from shared loader */
#else
___start(void (*cleanup)(void), /* from shared loader */
#endif /* __minix */
const Obj_Entry *obj, /* from shared loader */
struct ps_strings *ps_strings)
{
environ = envp;
#ifdef __minix
/* LSC: We have not yet updated the way we pass arguments to
the userspace, so here some code to adapt this to the new
ways. */
struct ps_strings minix_ps_strings;
if (argv[0] != NULL) {
if (ps_strings == NULL) {
minix_ps_strings.ps_envstr = envp;
minix_ps_strings.ps_argvstr = argv;
minix_ps_strings.ps_nargvstr = argc;
ps_strings = &minix_ps_strings;
}
#endif /* __minix */
if (ps_strings == NULL)
_FATAL("ps_strings missing\n");
__ps_strings = ps_strings;
environ = ps_strings->ps_envstr;
if (ps_strings->ps_argvstr[0] != NULL) {
char *c;
__progname = argv[0];
for (c = argv[0]; *c; ++c) {
__progname = ps_strings->ps_argvstr[0];
for (c = ps_strings->ps_argvstr[0]; *c; ++c) {
if (*c == '/')
__progname = c + 1;
}
@@ -114,17 +166,18 @@ ___start(int argc, char **argv, char **envp,
__progname = empty_string;
}
if (ps_strings != NULL)
__ps_strings = ps_strings;
if (&DYNAMIC_SYM != NULL) {
if ((obj == NULL) || (obj->magic != RTLD_MAGIC))
if (&rtld_DYNAMIC != NULL) {
if (obj == NULL)
_FATAL("NULL Obj_Entry pointer in GOT\n");
if (obj->magic != RTLD_MAGIC)
_FATAL("Corrupt Obj_Entry pointer in GOT\n");
if (obj->version != RTLD_VERSION)
_FATAL("Dynamic linker version mismatch\n");
atexit(cleanup);
}
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&__eprol, (u_long)&__etext);
@@ -133,5 +186,5 @@ ___start(int argc, char **argv, char **envp,
atexit(_fini);
_init();
exit(main(argc, argv, environ));
exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));
}

View File

@@ -6,11 +6,7 @@ ELFSIZE=32
.include "../../Makefile.inc"
.if defined(__MINIX) && ${MACHINE_ARCH} == "arm"
CPPFLAGS+= -DLIBC_SCCS -DPIC -DELFSIZE=${ELFSIZE}
.else
CPPFLAGS+= -DLIBC_SCCS -DPIC -DDYNAMIC -DELFSIZE=${ELFSIZE}
.endif
CPPFLAGS+= -I${NETBSDSRCDIR}/libexec/ld.elf_so
CPPFLAGS+= -I${.CURDIR}/../common_elf
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/dlfcn

View File

@@ -1,4 +1,4 @@
/* $NetBSD: common.h,v 1.13 2009/12/14 01:04:02 matt Exp $ */
/* $NetBSD: common.h,v 1.16 2012/03/21 10:09:20 matt Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -68,11 +68,12 @@ do { \
static char *_strrchr(char *, int);
char **environ;
char *__progname = "";
char *__progname = __UNCONST("");
struct ps_strings *__ps_strings = 0;
extern void _init(void);
extern void _fini(void);
extern void _libc_init(void);
#ifdef DYNAMIC
void _rtld_setup(void (*)(void), const Obj_Entry *obj);
@@ -83,7 +84,7 @@ void _rtld_setup(void (*)(void), const Obj_Entry *obj);
* if we happen to be compiling without -static but with without any
* shared libs present, things will still work.
*/
extern int _DYNAMIC __weak_reference(_DYNAMIC);
__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC);
#endif /* DYNAMIC */
#ifdef MCRT0

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.7 2004/08/26 21:07:14 thorpej Exp $ */
/* $NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 2002 Matt Fredette
@@ -89,31 +89,12 @@ ___start(struct ps_strings *ps_strings,
__ps_strings = ps_strings;
#ifdef DYNAMIC
/*
* XXX fredette - when not compiling PIC, you currently
* can't detect an undefined weak symbol by seeing if
* its address is NULL. The compiler emits code to find
* _DYNAMIC relative to %dp, the assembler notes the
* needed relocations, but when the linker sees that the
* (weak) symbol isn't defined it drops the ball - the
* relocations are never filled, and the binary ends up
* with code that sees an address of %dp plus zero,
* which != NULL.
*
* Arguably the linker could/should distinguish between
* code that is after a weak undefined symbol's contents
* from code that is after its address. In the first case,
* it would warn and/or bail. In the second case, it
* would fix up instructions to give a symbol address
* of NULL.
*
* For now, we take the easy way out and compare &_DYNAMIC
* to %dp, as well as to NULL.
*/
if (&_DYNAMIC != NULL && (int)&_DYNAMIC != dp)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -152,7 +133,7 @@ ___start(struct ps_strings *ps_strings,
* 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.7 2004/08/26 21:07:14 thorpej Exp $");
__RCSID("$NetBSD: crt0.c,v 1.10 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.2 2006/09/15 05:29:44 skrll Exp $ */
/* $NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -72,10 +72,12 @@ __start(char **sp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -91,7 +93,7 @@ __start(char **sp,
* 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.2 2006/09/15 05:29:44 skrll Exp $");
__RCSID("$NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.11 2004/08/26 21:09:52 thorpej Exp $ */
/* $NetBSD: crt0.c,v 1.13 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1999 Klaus Klein
@@ -75,10 +75,12 @@ __start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -94,7 +96,7 @@ __start(int argc, char **argv, char **envp,
* 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.11 2004/08/26 21:09:52 thorpej Exp $");
__RCSID("$NetBSD: crt0.c,v 1.13 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.20 2009/12/14 01:04:02 matt Exp $ */
/* $NetBSD: crt0.c,v 1.22 2011/02/22 05:45:07 joerg Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -52,13 +52,13 @@
* as well as the usual registers (pc, sp, and t9 == pc for ABI).
*/
void __start(u_long, void (*)(void), const Obj_Entry *,
void __start(uintptr_t, void (*)(void), const Obj_Entry *,
struct ps_strings *);
__asm(".text; .align 4; .globl _start; _start:");
void
__start(u_long sp,
__start(uintptr_t sp,
void (*cleanup)(void), /* from shared loader */
const Obj_Entry *obj, /* from shared loader */
struct ps_strings *ps_strings)
@@ -118,7 +118,7 @@ __start(u_long sp,
#endif
argc = *(int *)ksp;
argc = *(long *)ksp;
argv = ksp + 1;
environ = ksp + 2 + argc; /* 2: argc + NULL ending argv */
@@ -142,14 +142,14 @@ __start(u_long sp,
* XXX If we were loaded by that loader, just abort
* XXX the rtld setup.
*/
if (&_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
if (&rtld_DYNAMIC != NULL && cleanup != NULL && obj != NULL)
_rtld_setup(cleanup, obj);
#endif
}
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
monstartup((uintptr_t)&_eprol, (uintptr_t)&_etext);
#endif
atexit(_fini);
@@ -163,7 +163,7 @@ __start(u_long sp,
* is the entrypoint. (Only needed for old toolchains).
*/
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: crt0.c,v 1.20 2009/12/14 01:04:02 matt Exp $");
__RCSID("$NetBSD: crt0.c,v 1.22 2011/02/22 05:45:07 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.26 2006/05/18 17:54:19 christos Exp $ */
/* $NetBSD: crt0.c,v 1.30 2011/03/12 07:56:36 matt Exp $ */
/*
* Copyright (c) 1997 Jason R. Thorpe.
@@ -41,8 +41,8 @@
* Small Data Area designators. If not defined, will show up as being
* at address zero.
*/
extern int _SDA_BASE_[] __weak_reference(_SDA_BASE_);
extern int _SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
__weakref_visible int rtld_SDA_BASE_[] __weak_reference(_SDA_BASE_);
__weakref_visible int rtld_SDA2_BASE_[] __weak_reference(_SDA2_BASE_);
/*
* First 5 arguments are specified by the PowerPC SVR4 ABI. The
@@ -62,12 +62,15 @@ _start(int argc, char **argv, char **envp,
/*
* Initialize the Small Data Area registers.
* _SDA_BASE is defined in the SVR4 ABI for PPC.
* _SDA2_BASE is defined in the E[mbedded] ABI for PPC.
*
* Do the initialization in a PIC manner.
*/
__asm( "lis %r13,_SDA_BASE_@ha;"
"addi %r13,%r13,_SDA_BASE_@l;"
"lis %r2,_SDA2_BASE_@ha;"
"addi %r2,%r2,_SDA2_BASE_@l" );
__asm(
"bcl 20,31,1f;"
"1: mflr 11;"
"addis 13,11,rtld_SDA_BASE_-1b@ha;"
"addi 13,13,rtld_SDA_BASE_-1b@l;"
::: "lr" );
if ((namep = argv[0]) != NULL) { /* NULL ptr if argc = 0 */
if ((__progname = _strrchr(namep, '/')) == NULL)
@@ -82,10 +85,12 @@ _start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -101,7 +106,7 @@ _start(int argc, char **argv, char **envp,
* 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.26 2006/05/18 17:54:19 christos Exp $");
__RCSID("$NetBSD: crt0.c,v 1.30 2011/03/12 07:56:36 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: dot_init.h,v 1.7 2008/05/10 15:31:04 martin Exp $ */
/* $NetBSD: dot_init.h,v 1.8 2011/07/02 07:28:08 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -40,18 +40,18 @@
".section "#sect",\"ax\",@progbits \n" \
".global "#entry_pt" \n" \
#entry_pt": \n" \
" stwu %r1,-16(%r1) \n" \
" mflr %r0 \n" \
" stw %r0,12(%r1) \n" \
" stw %r0,4(%r1) \n" \
" stwu %r1,-16(%r1) \n" \
" /* fall thru */ \n" \
".previous")
#define MD_SECTION_EPILOGUE(sect) \
__asm ( \
".section "#sect",\"ax\",@progbits \n" \
" lwz %r0,12(%r1) \n" \
" addi %r1,%r1,16 \n" \
" lwz %r0,4(%r1) \n" \
" mtlr %r0 \n" \
" la %r1,16(%r1) \n" \
" blr \n" \
".previous")

View File

@@ -1,5 +1,5 @@
# $NetBSD: Makefile,v 1.1 2006/06/30 22:49:50 ross Exp $
# $NetBSD: Makefile,v 1.2 2011/10/29 10:28:37 mrg Exp $
CPPFLAGS+= -I- -I${.CURDIR}
CPPFLAGS+= -I${.CURDIR}
.include "${.CURDIR}/../common_elf/Makefile.inc"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.2 2006/07/01 01:39:17 ross Exp $ */
/* $NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $ */
/*
* Copyright (c) 1997 Jason R. Thorpe.
@@ -74,10 +74,12 @@ _start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -93,7 +95,7 @@ _start(int argc, char **argv, char **envp,
* 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.2 2006/07/01 01:39:17 ross Exp $");
__RCSID("$NetBSD: crt0.c,v 1.4 2011/03/07 05:09:10 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.10 2004/08/26 21:16:41 thorpej Exp $ */
/* $NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -69,10 +69,12 @@ ___start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -88,7 +90,7 @@ ___start(int argc, char **argv, char **envp,
* 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 2004/08/26 21:16:41 thorpej Exp $");
__RCSID("$NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.6 2006/05/19 19:11:12 christos Exp $
# $NetBSD: Makefile,v 1.9 2012/08/10 16:37:31 martin Exp $
#Uncomment the next line to enable the new .init fallthru
CPPFLAGS+= -I${.CURDIR}/../sparc_elf
CFLAGS+= -fPIC
ELFSIZE=64

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.24 2005/12/24 21:38:40 perry Exp $ */
/* $NetBSD: crt0.c,v 1.27 2012/08/10 16:37:31 martin Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou
@@ -45,8 +45,6 @@
*/
__asm("\n\
.data\n\
__data_start: ! Start of data section\n\
.text\n\
.align 4\n\
.global _start\n\
@@ -55,11 +53,9 @@ __data_start: ! Start of data section\n\
.register %g2,#scratch\n\
_start:\n\
__start:\n\
setx __data_start, %o0, %g4 ! Point %g4 to start of data section\n\
clr %g4 ! egcs thinks this is zero. XXX\n\
clr %g4 ! XXX depends on memory model used \n\
clr %fp\n\
add %sp, 8*16 + 0x7ff, %o0 ! start of stack\n\
mov %g1, %o1 ! Cleanup routine\n\
mov %g3, %o1 ! XXXX our rtld uses %g3\n\
mov %g2, %o2 ! XXXX obj from rtld.\n\
ba,pt %icc, ___start ! XXXX jump over the retl egcs 2.96 inserts\n\
@@ -94,10 +90,12 @@ ___start(char **sp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -113,7 +111,7 @@ ___start(char **sp,
* 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.24 2005/12/24 21:38:40 perry Exp $");
__RCSID("$NetBSD: crt0.c,v 1.27 2012/08/10 16:37:31 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.6 2006/05/19 19:11:12 christos Exp $
# $NetBSD: Makefile,v 1.7 2012/08/10 12:37:39 martin Exp $
#Uncomment the next line to enable the new .init fallthru
CPPFLAGS+= -I${.CURDIR}
CFLAGS+= -fPIC
.include "${.CURDIR}/../common_elf/Makefile.inc"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.12 2004/08/26 21:18:36 thorpej Exp $ */
/* $NetBSD: crt0.c,v 1.15 2012/08/10 12:37:39 martin Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
@@ -56,7 +56,7 @@ _start:\n\
sub %sp, 24, %sp ! expand to standard stack frame size\n\
mov %g3, %o3\n\
mov %g2, %o4\n\
call ___start\n\
ba ___start\n\
mov %g1, %o5\n\
");
@@ -79,10 +79,12 @@ ___start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -98,7 +100,7 @@ ___start(int argc, char **argv, char **envp,
* 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.12 2004/08/26 21:18:36 thorpej Exp $");
__RCSID("$NetBSD: crt0.c,v 1.15 2012/08/10 12:37:39 martin Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crt0.c,v 1.10 2004/08/26 21:24:09 thorpej Exp $ */
/* $NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
@@ -76,10 +76,12 @@ ___start(int argc, char **argv, char **envp,
__ps_strings = ps_strings;
#ifdef DYNAMIC
if (&_DYNAMIC != NULL)
if (&rtld_DYNAMIC != NULL)
_rtld_setup(cleanup, obj);
#endif
_libc_init();
#ifdef MCRT0
atexit(_mcleanup);
monstartup((u_long)&_eprol, (u_long)&_etext);
@@ -95,7 +97,7 @@ ___start(int argc, char **argv, char **envp,
* 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 2004/08/26 21:24:09 thorpej Exp $");
__RCSID("$NetBSD: crt0.c,v 1.12 2011/03/07 05:09:11 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "common.c"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: dot_init.h,v 1.7 2008/05/10 15:31:04 martin Exp $ */
/* $NetBSD: dot_init.h,v 1.8 2011/07/30 15:28:58 matt Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
@@ -34,7 +34,6 @@
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
#include <machine/asm.h>
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
__asm ( \

View File

@@ -49,13 +49,12 @@ BUILDCOLD?= no
SUBDIR=compat
.include <bsd.subdir.mk>
.else
.if !defined(__MINIX)
COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/compat/Makefile.inc"
.else
.if defined(__MINIX)
SUBDIR+= pkgconfig
.include <bsd.subdir.mk>
.endif
.endif # defined(__MINIX)
.endif
.include "${.CURDIR}/../../common/lib/libc/Makefile.inc"

View File

@@ -1,12 +1,24 @@
# $NetBSD: Makefile.inc,v 1.9 2010/07/06 05:59:52 mrg Exp $
# $NetBSD: Makefile.inc,v 1.16 2012/09/27 11:20:20 skrll Exp $
.include <bsd.own.mk>
.if !defined(__MINIX)
SRCS+= __sigaction14_sigtramp.c __sigtramp2.S
SRCS+= __aeabi_read_tp.S __sigaction14_sigtramp.c __sigtramp2.S
.endif
CPPFLAGS += -I.
CPPFLAGS += -DSOFTFLOAT
.if ${MACHINE_ARCH} == "earm" || ${MACHINE_ARCH} == "earmeb"
SRCS+= __aeabi_ldivmod.S __aeabi_uldivmod.S
SRCS+= __aeabi_lcmp.c __aeabi_ulcmp.c
SRCS+= fixunsgen_ieee754.c fixunssfsi_ieee754.c
SRCS+= fixunsgen64_ieee754.c fixunsdfsi_ieee754.c
.endif
# for earm, use the 64-bit softfloat
.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "armeb"
SOFTFLOAT_BITS=32
.endif
.include <softfloat/Makefile.inc>

View File

@@ -1,7 +1,7 @@
# $NetBSD: Makefile.inc,v 1.16 2009/12/06 07:12:17 uebayasi Exp $
# $NetBSD: Makefile.inc,v 1.19 2012/10/10 02:15:03 christos Exp $
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S bswap64.c divsi3.S \
fabs.c flt_rounds.c
fabs.c flt_rounds.c modsi3.S umodsi3.S
# Common ieee754 constants and functions
SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c

View File

@@ -1,4 +1,4 @@
/* $NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $ */
/* $NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $");
__RCSID("$NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -50,7 +50,7 @@ void
_lwp_makecontext(ucontext_t *u, void (*start)(void *),
void *arg, void *private, caddr_t stack_base, size_t stack_size)
{
void **sp;
uintptr_t sp;
getcontext(u);
u->uc_link = NULL;
@@ -58,14 +58,15 @@ _lwp_makecontext(ucontext_t *u, void (*start)(void *),
u->uc_stack.ss_sp = stack_base;
u->uc_stack.ss_size = stack_size;
sp = (void **) (stack_base + stack_size);
sp = (uintptr_t)stack_base + stack_size;
/*
* Note: We make sure the stack is 8-byte aligned, here.
*/
u->uc_mcontext.__gregs[_REG_R0] = (__greg_t) arg;
u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~7;
u->uc_mcontext.__gregs[_REG_LR] = (__greg_t) _lwp_exit;
u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
u->uc_mcontext.__gregs[_REG_R0] = (__greg_t)(uintptr_t)arg;
u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t)sp) & ~7;
u->uc_mcontext.__gregs[_REG_LR] = (__greg_t)(uintptr_t)_lwp_exit;
u->uc_mcontext.__gregs[_REG_PC] = (__greg_t)(uintptr_t)start;
u->uc_mcontext._mc_tlsbase = (__greg_t)(uintptr_t)private;
u->uc_flags |= _UC_TLSBASE;
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: _setjmp.S,v 1.6 2004/08/21 11:20:10 rearnsha Exp $ */
/* $NetBSD: _setjmp.S,v 1.7 2012/08/01 06:02:13 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -53,6 +53,8 @@ ENTRY(_setjmp)
str r1, [r0], #4
#ifdef SOFTFLOAT
add r0, r0, #52
#elif defined(__VFP_FP__)
#error _setjmp VFP support missing
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
@@ -77,6 +79,8 @@ ENTRY(_longjmp)
#ifdef SOFTFLOAT
add r0, r0, #52
#elif defined(__VFP_FP__)
#error _longjmp VFP support missing
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48

View File

@@ -1,4 +1,4 @@
/* $NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $ */
/* $NetBSD: flt_rounds.c,v 1.4 2012/03/21 20:04:57 he Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $");
__RCSID("$NetBSD: flt_rounds.c,v 1.4 2012/03/21 20:04:57 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -75,7 +75,7 @@ static const int map[] = {
int __flt_rounds(void);
int
__flt_rounds()
__flt_rounds(void)
{
return(map[fpgetround()]);
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:55 martin Exp $ */
/* $NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:55 martin Exp $");
__RCSID("$NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $");
#endif
#include <stddef.h>
@@ -55,12 +55,12 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
/* Allocate necessary stack space for arguments exceeding r0-3. */
if (argc > 4)
sp -= argc - 4;
gr[_REG_SP] = (__greg_t)sp;
gr[_REG_SP] = (__greg_t)(uintptr_t)sp;
/* Wipe out frame pointer. */
gr[_REG_FP] = 0;
/* Arrange for return via the trampoline code. */
gr[_REG_LR] = (__greg_t)_resumecontext;
gr[_REG_PC] = (__greg_t)func;
gr[_REG_LR] = (__greg_t)(uintptr_t)_resumecontext;
gr[_REG_PC] = (__greg_t)(uintptr_t)func;
va_start(ap, argc);
/* Pass up to four arguments in r0-3. */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: resumecontext.c,v 1.4 2008/04/28 20:22:55 martin Exp $ */
/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: resumecontext.c,v 1.4 2008/04/28 20:22:55 martin Exp $");
__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $");
#endif
#include "namespace.h"
@@ -41,7 +41,7 @@ __RCSID("$NetBSD: resumecontext.c,v 1.4 2008/04/28 20:22:55 martin Exp $");
#include "extern.h"
void
_resumecontext()
_resumecontext(void)
{
ucontext_t uct;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: setjmp.S,v 1.8 2005/10/16 17:26:24 christos Exp $ */
/* $NetBSD: setjmp.S,v 1.9 2012/08/01 06:02:13 matt Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
@@ -59,6 +59,8 @@ ENTRY(__setjmp14)
#ifdef SOFTFLOAT
add r0, r0, #52
#elif defined(__VFP_FP__)
#error __setjmp14 VFP support missing
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
@@ -92,6 +94,8 @@ ENTRY(__longjmp14)
add r0, r0, #4
#ifdef SOFTFLOAT
add r0, r0, #52
#elif defined(__VFP_FP__)
#error __longjmp14 VFP support missing
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48

View File

@@ -1,4 +1,4 @@
/* $NetBSD: swapcontext.S,v 1.5 2008/04/28 20:22:55 martin Exp $ */
/* $NetBSD: swapcontext.S,v 1.8 2012/09/27 11:20:20 skrll Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,18 +30,22 @@
*/
#include "SYS.h"
#include "assym.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.5 2008/04/28 20:22:55 martin Exp $")
RCSID("$NetBSD: swapcontext.S,v 1.8 2012/09/27 11:20:20 skrll Exp $")
#endif /* LIBC_SCCS && !lint */
ENTRY(swapcontext)
stmfd sp!, {r0-r1, lr} /* Must save oucp, ucp, lr. */
sub sp, #4
bl PIC_SYM(_C_LABEL(_getcontext), PLT) /* getcontext(oucp) */
cmp r0, #0
add sp, #4
ldmfd sp!, {r0-r1, lr}
RETc(ne)
str lr, [r0, #(36 + 15*4)] /* Adjust saved PC. */
str sp, [r0, #_UC_REGS_SP] /* Adjust saved SP. */
str lr, [r0, #_UC_REGS_PC] /* Adjust saved PC. */
#ifdef SOFTFLOAT
/* Ahem. */
#endif

View File

@@ -0,0 +1,36 @@
# $NetBSD: genassym.cf,v 1.1 2012/09/27 11:20:20 skrll Exp $
#
# Copyright (c) 2012 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 <sys/types.h>
include <ucontext.h>
define _UC_REGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP])
define _UC_REGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC])

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpgetmask.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
/* $NetBSD: fpgetmask.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -45,7 +45,11 @@ ENTRY(_fpgetmask)
#else
ENTRY(fpgetmask)
#endif
#ifdef __VFP_FP__
#error _fpgetmask VFP support missing
#else
rfs r0
mov r0, r0, lsr #16
and r0, r0, #0x1f
RET
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpgetround.c,v 1.4 2006/02/25 02:28:55 wiz Exp $ */
/* $NetBSD: fpgetround.c,v 1.5 2012/06/24 15:26:02 christos Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fpgetround.c,v 1.4 2006/02/25 02:28:55 wiz Exp $");
__RCSID("$NetBSD: fpgetround.c,v 1.5 2012/06/24 15:26:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -65,7 +65,7 @@ __weak_alias(fpgetround,_fpgetround)
*/
fp_rnd
fpgetround()
fpgetround(void)
{
return(FP_RN);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpgetsticky.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
/* $NetBSD: fpgetsticky.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -45,6 +45,10 @@ ENTRY(_fpgetsticky)
#else
ENTRY(fpgetsticky)
#endif
#ifdef __VFP_FP__
#error _fpgetsticky VFP support missing
#else
rfs r0
and r0, r0, #0x1f
RET
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpsetmask.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
/* $NetBSD: fpsetmask.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -45,6 +45,9 @@ ENTRY(_fpsetmask)
#else
ENTRY(fpsetmask)
#endif
#ifdef __VFP_FP__
#error _fpsetmask VFP support missing
#else
rfs r1
bic r1, r1, #0x001f0000
and r0, r0, #0x0000001f
@@ -52,3 +55,4 @@ ENTRY(fpsetmask)
wfs r0
mov r0, r1, lsr #16 /* Return old mask */
RET
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpsetsticky.S,v 1.4 2004/08/21 11:21:00 rearnsha Exp $ */
/* $NetBSD: fpsetsticky.S,v 1.5 2012/08/01 06:10:21 matt Exp $ */
/*
* Copyright (c) 1996 Mark Brinicombe
@@ -45,6 +45,9 @@ ENTRY(_fpsetsticky)
#else
ENTRY(fpsetsticky)
#endif
#ifdef __VFP_FP__
#error _fpsetsticky VFP support missing
#else
rfs r1
bic r1, r1, #0x1f
and r0, r0, #0x1f
@@ -52,3 +55,4 @@ ENTRY(fpsetsticky)
wfs r0
mov r0, r1 /* Return old mask */
RET
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: softfloat.h,v 1.7 2006/05/16 20:55:51 mrg Exp $ */
/* $NetBSD: softfloat.h,v 1.9 2011/07/07 07:14:57 matt Exp $ */
/* This is a derivative work. */
@@ -84,12 +84,10 @@ Software IEC/IEEE floating-point rounding mode.
-------------------------------------------------------------------------------
*/
extern fp_rnd float_rounding_mode;
enum {
float_round_nearest_even = FP_RN,
float_round_to_zero = FP_RZ,
float_round_down = FP_RM,
float_round_up = FP_RP
};
#define float_round_nearest_even FP_RN
#define float_round_to_zero FP_RZ
#define float_round_down FP_RM
#define float_round_up FP_RP
/*
-------------------------------------------------------------------------------
@@ -119,13 +117,17 @@ void float_raise( fp_except );
Software IEC/IEEE integer-to-floating-point conversion routines.
-------------------------------------------------------------------------------
*/
float32 int32_to_float32( int );
float64 int32_to_float64( int );
float32 int32_to_float32( int32 );
float32 uint32_to_float32( uint32 );
float64 int32_to_float64( int32 );
float64 uint32_to_float64( uint32 );
#ifdef FLOATX80
floatx80 int32_to_floatx80( int );
floatx80 int32_to_floatx80( int32 );
floatx80 uint32_to_floatx80( uint32 );
#endif
#ifdef FLOAT128
float128 int32_to_float128( int );
float128 int32_to_float128( int32 );
float128 uint32_to_float128( uint32 );
#endif
#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */
float32 int64_to_float32( long long );

View File

@@ -2,9 +2,8 @@
HERE=${.CURDIR}/arch/${MACHINE_ARCH}/sys-minix
.PATH: ${HERE}
ARCHINCLS=${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include/
TMP=ucontextoffsets.h.tmp
INCLS=../../include
ARCHINCLS=$(INCLS)/arch/arm/include/
CF=ucontextoffsets.cf
INCS+=ucontextoffsets.h
@@ -18,8 +17,9 @@ SRCS+= \
brksize.S \
ucontext.S
ucontextoffsets.h: $(CF) $(ARCHINCLS)/stackframe.h $(INCLS)/sys/ucontext.h
ucontextoffsets.h: ${CF} ${ARCHINCLS}/stackframe.h ${NETBSDSRCDIR}/sys/sys/ucontext.h
${_MKTARGET_CREATE}
cat ${HERE}/$(CF) | \
${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$TMP && \
mv -f $TMP $@

View File

@@ -0,0 +1,13 @@
#include "SYS.h"
ENTRY(__aeabi_read_tp)
mrc p15, 0, r0, c13, c0, 3
#ifndef _ARM_ARCH_6
cmp r0, #0 /* was it zero? */
RETc(ne) /* return it's not zero */
push {r1} /* syscall zeroes r1 */
SYSTRAP(_lwp_getprivate) /* can't fail */
pop {r1} /* restore r1 */
#endif
RET
_END(__aeabi_read_tp)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: brk.S,v 1.8 2004/08/21 11:30:17 rearnsha Exp $ */
/* $NetBSD: brk.S,v 1.9 2011/05/13 23:14:36 nonaka Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -33,7 +33,7 @@
#include "SYS.h"
.globl _C_LABEL(end)
.globl _C_LABEL(_end)
.globl CURBRK
#ifdef WEAK_ALIAS
@@ -45,7 +45,7 @@ WEAK_ALIAS(brk, _brk)
.globl _C_LABEL(__minbrk)
.type _C_LABEL(__minbrk),#object
_C_LABEL(__minbrk):
.word _C_LABEL(end)
.word _C_LABEL(_end)
/*
* Change the data segment size

View File

@@ -1,4 +1,4 @@
/* $NetBSD: cerror.S,v 1.7 2011/01/14 06:12:17 matt Exp $ */
/* $NetBSD: cerror.S,v 1.8 2012/02/27 12:26:21 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -34,7 +34,7 @@
#include "SYS.h"
#ifdef PIC
.hidden CERROR
.protected CERROR
#endif
ASENTRY(CERROR)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: sbrk.S,v 1.8 2004/08/21 11:30:17 rearnsha Exp $ */
/* $NetBSD: sbrk.S,v 1.9 2011/05/13 23:14:36 nonaka Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -33,7 +33,7 @@
#include "SYS.h"
.globl _C_LABEL(end)
.globl _C_LABEL(_end)
#ifdef WEAK_ALIAS
WEAK_ALIAS(sbrk, _sbrk)
@@ -44,7 +44,7 @@ WEAK_ALIAS(sbrk, _sbrk)
.globl CURBRK
.type CURBRK,#object
CURBRK:
.word _C_LABEL(end)
.word _C_LABEL(_end)
/*
* Change the data segment size

View File

@@ -1,4 +1,4 @@
/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
/* $NetBSD: gd_qnan.h,v 1.2 2011/06/05 14:43:12 christos Exp $ */
#define f_QNAN 0x7fc00000
#define d_QNAN0 0x0
@@ -6,6 +6,6 @@
#define ldus_QNAN0 0x0
#define ldus_QNAN1 0x0
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0x4000
#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0x7fff
/* 2 bytes of tail padding follow, per i386 ABI */

View File

@@ -1,9 +1,10 @@
# $NetBSD: Makefile.inc,v 1.26 2009/12/06 07:12:17 uebayasi Exp $
# $NetBSD: Makefile.inc,v 1.27 2011/03/26 19:51:41 christos Exp $
# objects built from assembler sources (need lint stubs)
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S \
flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \
fpsetmask.S fpsetround.S fpsetsticky.S
fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
fpsetprec.S
SRCS+= setjmp.S _setjmp.S sigsetjmp.S

View File

@@ -1,4 +1,4 @@
/* $NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $ */
/* $NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $");
__RCSID("$NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -56,9 +56,9 @@ _lwp_makecontext(ucontext_t *u, void (*start)(void *),
/* LINTED uintptr_t is safe */
u->uc_mcontext.__gregs[_REG_EIP] = (uintptr_t)start;
/* Align to a word */
/* Align to a 16-byte boundary for SSE */
/* LINTED uintptr_t is safe */
sp = (void **) ((uintptr_t)(stack_base + stack_size) & ~0x3);
sp = (void **) (((uintptr_t)(stack_base + stack_size - 4) & ~0xf) + 4);
*--sp = arg;
*--sp = (void *) _lwp_exit;
@@ -66,5 +66,6 @@ _lwp_makecontext(ucontext_t *u, void (*start)(void *),
/* LINTED uintptr_t is safe */
u->uc_mcontext.__gregs[_REG_UESP] = (uintptr_t) sp;
/* LINTED private is currently unused */
u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
u->uc_flags |= _UC_TLSBASE;
}

View File

@@ -0,0 +1,77 @@
/* $NetBSD: _setjmp.S,v 1.8 2005/10/05 20:18:12 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* from: @(#)_setjmp.s 5.1 (Berkeley) 4/23/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: _setjmp.S,v 1.8 2005/10/05 20:18:12 christos Exp $")
#endif
/*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v)" from the last call to
* _setjmp(a)
* by restoring registers from the stack.
* The previous signal state is NOT restored.
*/
ENTRY(_setjmp)
movl 4(%esp),%eax
movl 0(%esp),%edx
movl %edx, 0(%eax) /* rta */
movl %ebx, 4(%eax)
movl %esp, 8(%eax)
movl %ebp,12(%eax)
movl %esi,16(%eax)
movl %edi,20(%eax)
xorl %eax,%eax
ret
ENTRY(_longjmp)
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
movl 4(%edx),%ebx
movl 8(%edx),%esp
movl 12(%edx),%ebp
movl 16(%edx),%esi
movl 20(%edx),%edi
testl %eax,%eax
jnz 1f
incl %eax
1: movl %ecx,0(%esp)
ret

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fixunsdfsi.S,v 1.11 2003/08/07 16:42:07 agc Exp $ */
/* $NetBSD: fixunsdfsi.S,v 1.12 2011/05/22 20:11:47 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: fixunsdfsi.S,v 1.11 2003/08/07 16:42:07 agc Exp $")
RCSID("$NetBSD: fixunsdfsi.S,v 1.12 2011/05/22 20:11:47 joerg Exp $")
#endif
ENTRY(__fixunsdfsi)
@@ -72,4 +72,4 @@ ENTRY(__fixunsdfsi)
orl $0x80000000,%eax /* restore bias */
ret
fbiggestsigned: .double 0r2147483648.0
fbiggestsigned: .double 2147483648.0

View File

@@ -1,33 +1,21 @@
/* $NetBSD: flt_rounds.S,v 1.6 1999/08/23 08:45:09 kleink Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
* Public domain.
*/
/* $NetBSD: flt_rounds.S,v 1.9 2011/09/30 23:42:00 christos Exp $ */
#include <machine/asm.h>
/*
* 00 0 round to zero
* 01 1 round to nearest
* 10 2 round to positive infinity
* 11 3 round to negative infinity
*/
.text
_ALIGN_TEXT
_map:
.byte 1 /* round to nearest */
.byte 3 /* round to negative infinity */
.byte 2 /* round to positive infinity */
.byte 0 /* round to zero */
ENTRY(__flt_rounds)
subl $4,%esp
fnstcw (%esp)
movl (%esp),%eax
shrl $10,%eax
andl $3,%eax
#ifdef PIC
PIC_PROLOGUE
leal PIC_GOTOFF(_map),%ecx
PIC_EPILOGUE
movb (%ecx,%eax,1),%al
#else
movb _map(,%eax,1),%al
#endif
addl $4,%esp
fnstcw -4(%esp)
movl -4(%esp), %ecx
shrl $9, %ecx
andl $6, %ecx
movl $0x2d, %eax /* 0x2d = 00.10.11.01 */
sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */
andl $3, %eax
ret

View File

@@ -0,0 +1,22 @@
/* $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
* Public domain.
*/
#include <machine/asm.h>
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpgetprec, _fpgetprec)
ENTRY(_fpgetprec)
#else
ENTRY(fpgetprec)
#endif
subl $4,%esp
fnstcw (%esp)
movl (%esp),%eax
rorl $8,%eax
andl $3,%eax
addl $4,%esp
ret

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fpgetround.S,v 1.5 2002/01/13 21:45:43 thorpej Exp $ */
/* $NetBSD: fpgetround.S,v 1.6 2011/09/30 23:42:00 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
@@ -7,16 +7,17 @@
#include <machine/asm.h>
/*
* XXX load only x87 state.
*/
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpgetround, _fpgetround)
ENTRY(_fpgetround)
#else
ENTRY(fpgetround)
#endif
subl $4,%esp
fnstcw (%esp)
movl (%esp),%eax
rorl $10,%eax
andl $3,%eax
addl $4,%esp
fnstcw -4(%esp)
movl -4(%esp), %eax
andl $0x00000c00, %eax
ret

View File

@@ -0,0 +1,34 @@
/* $NetBSD: fpsetprec.S,v 1.1 2011/03/26 19:51:41 christos Exp $ */
/*
* Written by Charles M. Hannum, Apr 9, 1995
* Public domain.
*/
#include <machine/asm.h>
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpsetprec, _fpsetprec)
ENTRY(_fpsetprec)
#else
ENTRY(fpsetprec)
#endif
subl $4,%esp
fnstcw (%esp)
movl (%esp),%eax
rorl $8,%eax
movl %eax,%edx
andl $3,%eax
subl %eax,%edx
movl 8(%esp),%ecx
andl $3,%ecx
orl %ecx,%edx
roll $8,%edx
movl %edx,(%esp)
fldcw (%esp)
addl $4,%esp
ret

View File

@@ -1,34 +1,33 @@
/* $NetBSD: fpsetround.S,v 1.3 2002/01/13 21:45:43 thorpej Exp $ */
/* $NetBSD: fpsetround.S,v 1.5 2011/09/30 23:45:41 christos Exp $ */
/*
* Written by Charles M. Hannum, Apr 9, 1995
* Written by Frank van der Linden at Wasabi Systems for NetBSD.
* Public domain.
*/
#include <machine/asm.h>
/*
* XXX set both the x87 control word
* Applications should only set exception and round flags
*/
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpsetround, _fpsetround)
ENTRY(_fpsetround)
#else
ENTRY(fpsetround)
#endif
subl $4,%esp
fnstcw (%esp)
movl (%esp),%eax
fnstcw -4(%esp)
movl -4(%esp), %edx
movl %edx, %eax
andl $0x00000c00, %eax
andl $0xfffff3ff, %edx
movl 4(%esp), %ecx
orl %ecx, %edx
movl %edx, -4(%esp)
fldcw -4(%esp)
rorl $10,%eax
movl %eax,%edx
andl $3,%eax
subl %eax,%edx
movl 8(%esp),%ecx
andl $3,%ecx
orl %ecx,%edx
roll $10,%edx
movl %edx,(%esp)
fldcw (%esp)
addl $4,%esp
ret

View File

@@ -1,4 +1,4 @@
/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $ */
/* $NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:30 drochner Exp $ */
/*
* IEEE-compatible infinityl.c for little-endian 80-bit format -- public domain.
@@ -7,7 +7,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $");
__RCSID("$NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:30 drochner Exp $");
#endif /* LIBC_SCCS and not lint */
#include <math.h>

View File

@@ -1,4 +1,4 @@
/* $NetBSD: isnanl.c,v 1.6 2007/02/02 23:14:09 christos Exp $ */
/* $NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: isnanl.c,v 1.6 2007/02/02 23:14:09 christos Exp $");
__RCSID("$NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: div.S,v 1.8 2003/07/26 19:24:33 salo Exp $ */
/* $NetBSD: div.S,v 1.9 2011/06/12 20:29:25 plunky Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
@@ -7,7 +7,7 @@
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: div.S,v 1.8 2003/07/26 19:24:33 salo Exp $")
RCSID("$NetBSD: div.S,v 1.9 2011/06/12 20:29:25 plunky Exp $")
#endif
ENTRY(div)
@@ -19,5 +19,6 @@ ENTRY(div)
idiv %ecx
movl %eax,(%ebx)
movl %edx,4(%ebx)
movl %ebx,%eax
popl %ebx
ret $4

View File

@@ -1,4 +1,4 @@
/* $NetBSD: ldiv.S,v 1.8 2003/07/26 19:24:33 salo Exp $ */
/* $NetBSD: ldiv.S,v 1.9 2011/06/12 20:29:25 plunky Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
@@ -7,7 +7,7 @@
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: ldiv.S,v 1.8 2003/07/26 19:24:33 salo Exp $")
RCSID("$NetBSD: ldiv.S,v 1.9 2011/06/12 20:29:25 plunky Exp $")
#endif
ENTRY(ldiv)
@@ -19,5 +19,6 @@ ENTRY(ldiv)
idiv %ecx
movl %eax,(%ebx)
movl %edx,4(%ebx)
movl %ebx,%eax
popl %ebx
ret $4

View File

@@ -1,4 +1,4 @@
/* $NetBSD: __clone.S,v 1.3 2001/07/18 12:24:53 fvdl Exp $ */
/* $NetBSD: __clone.S,v 1.4 2011/11/18 20:21:41 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -100,11 +100,4 @@ ENTRY(__clone)
addl $12,%esp
5:
popl %ebp
#ifdef PIC
PIC_PROLOGUE
movl PIC_GOT(CERROR),%edx
PIC_EPILOGUE
jmp *%edx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: __syscall.S,v 1.3 2003/08/07 16:42:08 agc Exp $ */
/* $NetBSD: __syscall.S,v 1.4 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: __syscall.S,v 1.3 2003/08/07 16:42:08 agc Exp $")
RCSID("$NetBSD: __syscall.S,v 1.4 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -52,11 +52,4 @@ ENTRY(__syscall)
jc err
ret
err:
#ifdef PIC
PIC_PROLOGUE
mov PIC_GOT(CERROR), %ecx
PIC_EPILOGUE
jmp *%ecx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: __vfork14.S,v 1.8 2007/03/09 14:30:48 ad Exp $ */
/* $NetBSD: __vfork14.S,v 1.9 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: __vfork14.S,v 1.8 2007/03/09 14:30:48 ad Exp $")
RCSID("$NetBSD: __vfork14.S,v 1.9 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -57,11 +57,4 @@ ENTRY(__vfork14)
jmp *%ecx
err:
pushl %ecx
#ifdef PIC
PIC_PROLOGUE
mov PIC_GOT(CERROR), %ecx
PIC_EPILOGUE
jmp *%ecx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: brk.S,v 1.21 2007/03/09 14:30:56 ad Exp $ */
/* $NetBSD: brk.S,v 1.22 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: brk.S,v 1.21 2007/03/09 14:30:56 ad Exp $")
RCSID("$NetBSD: brk.S,v 1.22 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -74,10 +74,7 @@ ENTRY(_brk)
xorl %eax,%eax
ret
err:
PIC_PROLOGUE
mov PIC_GOT(CERROR),%edx
PIC_EPILOGUE
jmp *%edx
jmp CERROR
#else
movl 4(%esp),%ecx
cmpl %ecx,_C_LABEL(__minbrk)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: cerror.S,v 1.14 2003/08/07 16:42:08 agc Exp $ */
/* $NetBSD: cerror.S,v 1.16 2012/02/27 12:26:21 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,12 +36,13 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: cerror.S,v 1.14 2003/08/07 16:42:08 agc Exp $")
RCSID("$NetBSD: cerror.S,v 1.16 2012/02/27 12:26:21 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
.globl _C_LABEL(__errno)
.protected CERROR
_ENTRY(CERROR)
pushl %eax

View File

@@ -1,4 +1,4 @@
/* $NetBSD: exect.S,v 1.13 2003/08/07 16:42:08 agc Exp $ */
/* $NetBSD: exect.S,v 1.14 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: exect.S,v 1.13 2003/08/07 16:42:08 agc Exp $")
RCSID("$NetBSD: exect.S,v 1.14 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -47,11 +47,4 @@ ENTRY(exect)
orb $(PSL_T>>8),1(%esp)
popfl
SYSTRAP(execve)
#ifdef PIC
PIC_PROLOGUE
mov PIC_GOT(CERROR), %ecx
PIC_EPILOGUE
jmp *%ecx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: ptrace.S,v 1.16 2003/08/07 16:42:09 agc Exp $ */
/* $NetBSD: ptrace.S,v 1.17 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: ptrace.S,v 1.16 2003/08/07 16:42:09 agc Exp $")
RCSID("$NetBSD: ptrace.S,v 1.17 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -57,11 +57,4 @@ ENTRY(ptrace)
jc err
ret
err:
#ifdef PIC
PIC_PROLOGUE
mov PIC_GOT(CERROR), %ecx
PIC_EPILOGUE
jmp *%ecx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: sbrk.S,v 1.19 2008/07/02 20:07:43 rmind Exp $ */
/* $NetBSD: sbrk.S,v 1.20 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: sbrk.S,v 1.19 2008/07/02 20:07:43 rmind Exp $")
RCSID("$NetBSD: sbrk.S,v 1.20 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -73,10 +73,7 @@ ENTRY(_sbrk)
out:
ret
err:
PIC_PROLOGUE
mov PIC_GOT(CERROR),%edx
PIC_EPILOGUE
jmp *%edx
jmp CERROR
#else
movl 4(%esp),%ecx
movl CURBRK,%eax

View File

@@ -1,4 +1,4 @@
/* $NetBSD: syscall.S,v 1.11 2003/08/07 16:42:09 agc Exp $ */
/* $NetBSD: syscall.S,v 1.12 2011/11/18 20:21:41 joerg Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: syscall.S,v 1.11 2003/08/07 16:42:09 agc Exp $")
RCSID("$NetBSD: syscall.S,v 1.12 2011/11/18 20:21:41 joerg Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -50,11 +50,4 @@ ENTRY(syscall)
jc err
ret
err:
#ifdef PIC
PIC_PROLOGUE
mov PIC_GOT(CERROR), %ecx
PIC_EPILOGUE
jmp *%ecx
#else
jmp CERROR
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: swapcontext.S,v 1.6 2012/09/12 02:00:53 manu Exp $ */
/* $NetBSD: swapcontext.S,v 1.7 2012/09/13 11:47:46 martin Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: swapcontext.S,v 1.6 2012/09/12 02:00:53 manu Exp $")
RCSID("$NetBSD: swapcontext.S,v 1.7 2012/09/13 11:47:46 martin Exp $")
#endif /* LIBC_SCCS && !lint */
@@ -53,12 +53,12 @@ ENTRY(swapcontext)
#ifdef PIC
PIC_PROLOGUE(%g5,%o4) /* %g5 = _GLOBAL_OFFSET_TABLE */
#ifdef BIGPIC
set _C_LABEL(setcontext), %o6
ldx [%g5+%o6], %o5
set _C_LABEL(setcontext), %o5
ldx [%g5+%o5], %o4
#else
ldx [%g5+_C_LABEL(setcontext)], %o5
ldx [%g5+_C_LABEL(setcontext)], %o4
#endif
jmp %o5
jmp %o4
mov %o3, %o0
#else
ba,a _C_LABEL(setcontext)

View File

@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
* $NetBSD: SYS.h,v 1.10 2007/11/23 07:36:05 dsl Exp $
* $NetBSD: SYS.h,v 1.11 2011/11/18 20:43:01 joerg Exp $
*/
#include <machine/asm.h>
@@ -49,14 +49,8 @@
ENTRY(x); \
SYSTRAP(y)
#ifdef PIC
#define _SYSCALL_ERR \
mov PIC_GOT(CERROR), %rcx; \
jmp *%rcx
#else
#define _SYSCALL_ERR \
jmp CERROR
#endif
#define _SYSCALL(x,y) \
.text; _ALIGN_TEXT; \

View File

@@ -1,11 +1,15 @@
/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
/* $NetBSD: gd_qnan.h,v 1.3 2011/06/05 14:43:13 christos Exp $ */
#define f_QNAN 0x7fc00000
#define d_QNAN0 0x0
#define d_QNAN1 0x7ff80000
#define ld_QNAN0 0x0
#define ld_QNAN1 0xc0000000
#define ld_QNAN2 0x7fff
#define ld_QNAN3 0x0
#define ldus_QNAN0 0x0
#define ldus_QNAN1 0x0
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0x4000
#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0x7fff
/* 6 bytes of tail padding follow, per AMD64 ABI */

View File

@@ -1,9 +1,10 @@
# $NetBSD: Makefile.inc,v 1.15 2010/01/14 02:09:46 joerg Exp $
# $NetBSD: Makefile.inc,v 1.16 2011/03/26 19:51:42 christos Exp $
# objects built from assembler sources (need lint stubs)
SRCS+= alloca.S byte_swap_2.S byte_swap_4.S byte_swap_8.S fabs.S \
flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \
fpsetmask.S fpsetround.S fpsetsticky.S
fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \
fpsetprec.S
SRCS+= __setjmp14.S
SRCS+= _setjmp.S

View File

@@ -1,4 +1,4 @@
/* $NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $ */
/* $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $");
__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -66,5 +66,6 @@ _lwp_makecontext(ucontext_t *u, void (*start)(void *),
/* LINTED uintptr_t is safe */
gr[_REG_URSP] = (uintptr_t) sp;
/* LINTED private is currently unused */
u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
u->uc_flags |= _UC_TLSBASE;
}

View File

@@ -1,29 +1,21 @@
/* $NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
* Public domain.
*/
/* $NetBSD: flt_rounds.S,v 1.6 2011/09/30 17:42:34 christos Exp $ */
#include <machine/asm.h>
/*
* 00 0 round to zero
* 01 1 round to nearest
* 10 2 round to positive infinity
* 11 3 round to negative infinity
*/
.text
_ALIGN_TEXT
_map:
.byte 1 /* round to nearest */
.byte 3 /* round to negative infinity */
.byte 2 /* round to positive infinity */
.byte 0 /* round to zero */
ENTRY(__flt_rounds)
fnstcw -4(%rsp)
movl -4(%rsp),%eax
shrl $10,%eax
andl $3,%eax
#ifdef PIC
leaq PIC_GOT(_map),%rcx
movb (%rcx,%rax,1),%al
#else
movb _map(,%rax,1),%al
#endif
fnstcw -4(%rsp)
movl -4(%rsp), %ecx
shrl $9, %ecx
andl $6, %ecx
movl $0x2d, %eax /* 0x2d = 00.10.11.01 */
sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */
andl $3, %eax
ret

View File

@@ -0,0 +1,25 @@
/* $NetBSD: fpgetprec.S,v 1.1 2011/03/26 19:51:42 christos Exp $ */
/*
* Written by J.T. Conklin, Apr 4, 1995
* Public domain.
*/
#include <machine/asm.h>
/*
* XXX store only x87 state. If an application only uses the fp*
* interface, this should be in sync with the SSE mxcsr register.
*/
#ifdef WEAK_ALIAS
WEAK_ALIAS(fpgetprec, _fpgetprec)
ENTRY(_fpgetprec)
#else
ENTRY(fpgetprec)
#endif
fnstcw -4(%rsp)
movl -4(%rsp),%eax
rorl $8,%eax
andl $3,%eax
ret

Some files were not shown because too many files have changed in this diff Show More