Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/csu Add a common crtbegin.c file and use a machine depen...



details:   https://anonhg.NetBSD.org/src/rev/8b333fd2c86f
branches:  trunk
changeset: 787526:8b333fd2c86f
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Jun 22 02:37:09 2013 +0000

description:
Add a common crtbegin.c file and use a machine dependent crtbegin.h to
fill in .init/.fini.
Add mips support for USE_COMPILERCRTSTUFF=no (compiled only)

diffstat:

 lib/csu/arch/mips/Makefile.inc |    3 +
 lib/csu/arch/mips/crt0.S       |   56 +++++++++++++++++++++
 lib/csu/arch/mips/crtbegin.h   |   37 ++++++++++++++
 lib/csu/arch/mips/crtend.S     |   55 +++++++++++++++++++++
 lib/csu/arch/mips/crti.S       |   54 +++++++++++++++++++++
 lib/csu/arch/mips/crtn.S       |   44 +++++++++++++++++
 lib/csu/common/Makefile.inc    |   10 +-
 lib/csu/common/crtbegin.c      |  105 +++++++++++++++++++++++++++++++++++++++++
 8 files changed, 359 insertions(+), 5 deletions(-)

diffs (truncated from 417 to 300 lines):

diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/Makefile.inc    Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,3 @@
+#      $NetBSD: Makefile.inc,v 1.1 2013/06/22 02:37:09 matt Exp $
+
+CPPFLAGS+=     -I${ARCHDIR}
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/crt0.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/crt0.S  Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,56 @@
+/* $NetBSD: crt0.S,v 1.1 2013/06/22 02:37:09 matt Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+RCSID("$NetBSD: crt0.S,v 1.1 2013/06/22 02:37:09 matt Exp $")
+
+STRONG_ALIAS(_start,__start)
+
+/*
+ *     Assumes kernel (or ld_elf.so) passes the following parameters to
+ *     user-space in registers:
+ *
+ *     a0      stack pointer (0 if setregs didn't fill this in)
+ *     a1      cleanup
+ *     a2      Obj_Entry
+ *     a3      ps_strings
+ *
+ *      XXX Does this violate the ABI?
+ *      as well as the usual registers (pc, sp, and t9 == pc for ABI).
+ */
+
+NESTED_NOPROFILE(__start, CALLFRAME_SIZ, ra)
+       move    a0, a1          /* cleanup */
+       move    a1, a2          /* Obj_Entry */
+       move    a2, a3          /* ps_strings */
+       j       _C_LABEL(___start)
+END(__start)
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/crtbegin.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/crtbegin.h      Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+__asm( "\n\t"
+       ".pushsection .init, \"ax\", @progbits" "\n\t"
+       "jal    __do_global_ctors_aux"          "\n\t"
+       ".popsection");
+__asm( "\n\t"
+       ".pushsection .fini, \"ax\", @progbits" "\n\t"
+       "jal    __do_global_dtors_aux"          "\n\t"
+       ".popsection");
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/crtend.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/crtend.S        Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,55 @@
+/*     $NetBSD: crtend.S,v 1.1 2013/06/22 02:37:09 matt Exp $  */
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+RCSID("$NetBSD: crtend.S,v 1.1 2013/06/22 02:37:09 matt Exp $")
+
+       .section        .ctors, "aw", @progbits
+       .p2align 2
+       .global         __CTOR_LIST_END__
+       .hidden         __CTOR_LIST_END__
+__CTOR_LIST_END__:
+       .word           0
+
+       .section        .dtors, "aw", @progbits
+       .p2align 2
+       .global         __DTOR_LIST_END__
+       .hidden         __DTOR_LIST_END__
+__DTOR_LIST_END__:
+       .word           0
+
+       .section        .eh_frame, "a", @progbits
+       .p2align 2
+       .space  4
+
+       .section        .jcr, "aw", @progbits
+       .p2align 2
+       .space  4
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/crti.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/crti.S  Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,54 @@
+/* $NetBSD: crti.S,v 1.1 2013/06/22 02:37: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 <mips/asm.h>
+
+RCSID("$NetBSD: crti.S,v 1.1 2013/06/22 02:37:09 matt Exp $")
+
+#include "sysident.S"
+
+       .section ".init", "ax", @progbits
+NESTED_NOPROFILE(_init, CALLFRAME_SIZ, ra)
+        SETUP_GP
+        PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame
+        SAVE_GP(CALLFRAME_GP)
+        SETUP_GP64(CALLFRAME_GP, _init)
+       REG_S   ra, CALLFRAME_RA(sp)    # save RA
+END(_init)
+
+       .section ".fini", "ax", @progbits
+NESTED_NOPROFILE(_fini, CALLFRAME_SIZ, ra)
+        SETUP_GP
+        PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame
+        SAVE_GP(CALLFRAME_GP)
+        SETUP_GP64(CALLFRAME_GP, _fini)
+       REG_S   ra, CALLFRAME_RA(sp)    # save RA
+END(_fini)
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/arch/mips/crtn.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/csu/arch/mips/crtn.S  Sat Jun 22 02:37:09 2013 +0000
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+
+RCSID("$NetBSD: crtn.S,v 1.1 2013/06/22 02:37:09 matt Exp $")
+
+       .section ".init", "ax", @progbits
+       RESTORE_GP64
+       REG_L   ra, CALLFRAME_RA(sp)
+       PTR_ADDU sp, sp, CALLFRAME_SIZ
+       jr      ra
+
+       .section ".fini", "ax", @progbits
+       RESTORE_GP64
+       REG_L   ra, CALLFRAME_RA(sp)
+       PTR_ADDU sp, sp, CALLFRAME_SIZ
+       jr      ra
diff -r 06a247bb11ce -r 8b333fd2c86f lib/csu/common/Makefile.inc
--- a/lib/csu/common/Makefile.inc       Sat Jun 22 02:33:44 2013 +0000
+++ b/lib/csu/common/Makefile.inc       Sat Jun 22 02:37:09 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.8 2013/06/22 02:21:58 matt Exp $
+#      $NetBSD: Makefile.inc,v 1.9 2013/06/22 02:37:09 matt Exp $
 
 .include <bsd.own.mk>
 
@@ -12,10 +12,10 @@
 
 realall: ${OBJS}
 
-.if exists(${ARCHDIR}/crtbegin.c)
+.if !exists(${ARCHDIR}/crtbegin.S)
 crtbegin.o: crtbegin.c
        ${_MKTARGET_COMPILE}
-       ${COMPILE.c} ${ARCHDIR}/crtbegin.c -o ${.TARGET}.o
+       ${COMPILE.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
 .else
 crtbegin.o: crtbegin.S
        ${_MKTARGET_COMPILE}
@@ -27,10 +27,10 @@
        ${OBJCOPY} -R .ident ${.TARGET}
 .endif
 
-.if exists(${ARCHDIR}/crtbegin.c)



Home | Main Index | Thread Index | Old Index