Add crtstuff for hppa. Lightly tested.

This commit is contained in:
skrll 2013-07-13 18:52:35 +00:00
parent a99b56e5d4
commit 3aa460b612
6 changed files with 270 additions and 0 deletions

View File

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

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

@ -0,0 +1,67 @@
/* $NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
.import _GLOBAL_OFFSET_TABLE_
.hidden ___start
STRONG_ALIAS(__start,_start)
/*
* void _start(struct ps_strings *ps_strings,
* void (*cleanup)(void),
* const Obj_Entry *obj);
*/
_ENTRY(_start)
.callinfo frame=0, calls
.entry
bl L$lpc, %r27
depi 0, 31, 2, %r27
L$lpc: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8), %r27
ldo R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%r1),%r27
copy %r27, %r19
/*
* void ___start(void (*cleanup)(void),
* const Obj_Entry *obj,
* struct ps_strings *ps_strings);
*/
copy %arg0, %arg3 ; ps_strings -> tmp
copy %arg1, %arg0 ; cleanup -> arg0
copy %arg2, %arg1 ; obj -> arg1
b ___start
copy %arg3, %arg2 ; ps_strings (tmp) -> arg2
EXIT(_start)

View File

@ -0,0 +1,43 @@
/* $NetBSD*/
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
__asm( "\n\t"
".pushsection .init, \"ax\", @progbits" "\n\t"
"bl __do_global_ctors_aux, %rp" "\n\t"
" nop" "\n\t"
".popsection");
__asm( "\n\t"
".pushsection .fini, \"ax\", @progbits" "\n\t"
"bl __do_global_dtors_aux, %rp" "\n\t"
" nop" "\n\t"
".popsection");

View File

@ -0,0 +1,56 @@
/* $NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
.section .ctors, "aw", @progbits
.align 4
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.long 0
.section .dtors, "aw", @progbits
.align 4
.global __DTOR_LIST_END__
.hidden __DTOR_LIST_END__
__DTOR_LIST_END__:
.long 0
.section .eh_frame, "a", @progbits
.align 4
.long 0
.section .jcr, "aw", @progbits
.align 4
.long 0

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

@ -0,0 +1,55 @@
/* $NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
#include "sysident.S"
#define MD_SECTION_PROLOGUE(sect, entry_pt) \
.section sect,"ax",@progbits ! \
.global entry_pt ! \
.proc ! \
.callinfo frame=HPPA_FRAME_SIZE, calls, save_rp, save_sp, entry_gr=3 ! \
.entry ! \
entry_pt: ! \
stw %rp, HPPA_FRAME_CRP(%sp) ! \
copy %r3, %r1 ! \
copy %sp, %r3 ! \
stw,ma %r1, HPPA_FRAME_SIZE(%sp) ! \
/* fall thru */ ! \
.exit ! \
.procend ! \
.previous
MD_SECTION_PROLOGUE(.init, _init)
MD_SECTION_PROLOGUE(.fini, _fini)

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

@ -0,0 +1,46 @@
/* $NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $")
#define MD_SECTION_EPILOGUE(sect) \
.section #sect,"ax",@progbits ! \
ldw HPPA_FRAME_CRP(%r3) ,%rp ! \
ldo HPPA_FRAME_SIZE(%r3), %sp ! \
ldw,mb -HPPA_FRAME_SIZE(%sp), %r3 ! \
bv,n %r0(%rp) ! \
.previous
MD_SECTION_EPILOGUE(.init)
MD_SECTION_EPILOGUE(.fini)