Switch arm, earm, powerpc to use crtbegin.c
Use -fpie for crtbegin.
This commit is contained in:
parent
c194fe82de
commit
350cb9bc6c
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile.inc,v 1.5 2013/04/29 07:21:59 skrll Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.6 2013/06/27 21:24:39 matt Exp $
|
||||
|
||||
CPPFLAGS+= -DELFSIZE=32
|
||||
CPPFLAGS+= -I${ARCHDIR}
|
||||
.if (!empty(CPUFLAGS) && ${CPUFLAGS:M-mabi=aapcs*} != "")
|
||||
CPPFLAGS+= -DHAVE_INITFINI_ARRAY
|
||||
.endif
|
||||
|
|
|
@ -1,293 +0,0 @@
|
|||
/* $NetBSD: crtbegin.S,v 1.6 2013/06/24 14:49:13 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.6 2013/06/24 14:49:13 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,32
|
||||
.local __initialized
|
||||
.comm __initialized,1
|
||||
.local __finished
|
||||
.comm __finished,1
|
||||
|
||||
.text
|
||||
/*
|
||||
* All variables are local to this DSO so we can skip using GOT references
|
||||
* and instead use PCREL references to access them. We do this regardless
|
||||
* of being PIC since it isn't any additional overhead to do so.
|
||||
*
|
||||
* We don't setup a TOC since all of ours calls are indirect so it isn't
|
||||
* needed.
|
||||
*/
|
||||
|
||||
.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
|
|
@ -0,0 +1,38 @@
|
|||
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
__asm(
|
||||
".pushsection .init, \"ax\", %progbits"
|
||||
"\n\t" "bl __do_global_ctors_aux"
|
||||
"\n\t" ".popsection");
|
||||
|
||||
__asm(
|
||||
".pushsection .fini, \"ax\", %progbits"
|
||||
"\n\t" "bl __do_global_dtors_aux"
|
||||
"\n\t" ".popsection");
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: Makefile.inc,v 1.1 2012/08/13 02:49:04 matt Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $
|
||||
|
||||
CPPFLAGS+= -DELFSIZE=32
|
||||
CPPFLAGS+= -I${ARCHDIR}
|
||||
CPPFLAGS+= -DHAVE_INITFINI_ARRAY
|
||||
|
||||
|
|
|
@ -1,216 +0,0 @@
|
|||
/* $NetBSD: crtbegin.S,v 1.4 2013/06/24 20:56:18 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 2013/06/24 20:56:18 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(target1)
|
||||
.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,32,4
|
||||
|
||||
.section .init_array,"aw",%init_array
|
||||
.p2align 2
|
||||
.word __do_global_ctors_aux(target1)
|
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used;
|
||||
#ifdef SHARED
|
||||
static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used;
|
||||
#endif
|
||||
|
||||
#ifndef SHARED
|
||||
static const void *find_exidx(void *, int *) __used;
|
||||
|
||||
static const void *
|
||||
find_exidx(void * pc, int * pcount)
|
||||
{
|
||||
extern __dso_hidden const char __exidx_start[];
|
||||
extern __dso_hidden const char __exidx_end[];
|
||||
|
||||
*pcount = (__exidx_end - __exidx_start) / 8;
|
||||
return __exidx_start;
|
||||
}
|
||||
|
||||
__weak_alias(__gnu_Uwind_find_exidx,find_exidx)
|
||||
#endif /* !SHARED */
|
|
@ -1,5 +1,3 @@
|
|||
# $NetBSD: Makefile.inc,v 1.1 2011/02/08 02:02:25 matt Exp $
|
||||
|
||||
CPPFLAGS+= -DELFSIZE=32
|
||||
|
||||
# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $
|
||||
|
||||
CPPFLAGS+= -I${ARCHDIR}
|
||||
|
|
|
@ -1,268 +0,0 @@
|
|||
/* $NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <powerpc/asm.h>
|
||||
|
||||
RCSID("$NetBSD: crtbegin.S,v 1.2 2011/07/04 21:55:09 matt Exp $")
|
||||
|
||||
.section .ctors, "aw", @progbits
|
||||
.p2align 2
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
.section .dtors, "aw", @progbits
|
||||
.p2align 2
|
||||
__DTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
.section .eh_frame, "a", @progbits
|
||||
.p2align 2
|
||||
__EH_FRAME_LIST__:
|
||||
|
||||
.section .jcr, "aw", @progbits
|
||||
.p2align 2
|
||||
__JCR_LIST__:
|
||||
|
||||
.section ".got2","aw", @progbits
|
||||
.LCTOC = . + 32768
|
||||
|
||||
.section .data.rel, "aw", @progbits
|
||||
.p2align 2
|
||||
.type __dso_handle, @object
|
||||
.size __dso_handle, 4
|
||||
.globl __dso_handle
|
||||
.hidden __dso_handle
|
||||
__dso_handle:
|
||||
#ifdef SHARED
|
||||
.long __dso_handle
|
||||
#else
|
||||
.long 0
|
||||
#endif
|
||||
|
||||
.lcomm __dwarf_eh_object,8*SZREG,SZREG
|
||||
.lcomm __initialized,1,1
|
||||
.lcomm __finished,1,1
|
||||
|
||||
.text
|
||||
.weak __cxa_finalize
|
||||
.weak __deregister_frame_info
|
||||
.weak __register_frame_info
|
||||
.weak _Jv_RegisterClasses
|
||||
|
||||
/*
|
||||
* All variables are local to this DSO so we can skip using GOT references
|
||||
* and instead use PCREL references to access them. We do this regardless
|
||||
* of being PIC since it isn't any additional overhead to do so.
|
||||
*
|
||||
* We don't setup a TOC since all of ours calls are indirect so it isn't
|
||||
* needed.
|
||||
*/
|
||||
|
||||
__do_global_dtors_aux:
|
||||
mflr %r7 /* save return address */
|
||||
bcl 20,31,1f /* find out what address */
|
||||
1: mflr %r3 /* we are at */
|
||||
mtlr %r7 /* restore return address */
|
||||
|
||||
addis %r4,%r3,__finished-1b@ha /* PCREL ref (upper) */
|
||||
lbzu %r0,__finished-1b@l(%r4) /* PCREL ref (lower) & load */
|
||||
cmpwi %r0,0 /* done this already? */
|
||||
bnelr /* yep, return */
|
||||
|
||||
li %r0, 1
|
||||
stb %r0, 0(%r4) /* remember we've done this */
|
||||
|
||||
stw %r7,(1*SZREG)(%r1) /* save LR */
|
||||
stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
|
||||
stw %r31,(7*SZREG)(%r1) /* save some registers */
|
||||
stw %r30,(6*SZREG)(%r1)
|
||||
stw %r29,(5*SZREG)(%r1)
|
||||
stw %r28,(4*SZREG)(%r1)
|
||||
|
||||
mr %r29,%r3 /* move this to a safe place */
|
||||
|
||||
/*
|
||||
* Get a reference to our TOC.
|
||||
*/
|
||||
addis %r30,%r29,.LCTOC-1b@ha
|
||||
addi %r30,%r30,.LCTOC-1b@l
|
||||
|
||||
/*
|
||||
* Get a reference to the GOT.
|
||||
*/
|
||||
addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
|
||||
addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
|
||||
|
||||
#ifdef SHARED
|
||||
/*
|
||||
* if (__cxa_finalize)
|
||||
* __cxa_finalize(&__dso_handle);
|
||||
*/
|
||||
lwz %r0, __cxa_finalize@got(%r31)
|
||||
cmpwi %r0, 0
|
||||
beq 2f
|
||||
|
||||
addis %r3,%r29,__dso_handle-1b@ha /* get &__dso_handle (pcrel) */
|
||||
addi %r3,%r3,__dso_handle-1b@l
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
bctrl /* and call the routine */
|
||||
2:
|
||||
#endif
|
||||
|
||||
addis %r28,%r29,__DTOR_LIST__-1b@ha /* get &__DTOR_LIST__ */
|
||||
addi %r28,%r28,__DTOR_LIST__-1b@l
|
||||
/*
|
||||
* We know the first entry is -1 so skip it. We use load with update
|
||||
* to advance the pointer along.
|
||||
*/
|
||||
3:
|
||||
lwzu %r0, 4(%r28) /* get entry */
|
||||
cmpwi %r0, 0 /* end of list? */
|
||||
beq 4f /* yep. */
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
bctrl /* and call the routine */
|
||||
b 3b /* do it again */
|
||||
|
||||
4:
|
||||
/*
|
||||
* if (__deregister_frame_info)
|
||||
* __deregister_frame_info(&__EH_FRAME_LIST__[0]);
|
||||
*/
|
||||
lwz %r0,__deregister_frame_info@got(%r31)
|
||||
cmpwi %r0, 0 /* routine actually exist? */
|
||||
beq 5f /* nope, skip call */
|
||||
|
||||
addis %r3,%r29,__EH_FRAME_LIST__-1b@ha
|
||||
addi %r3,%r3,__EH_FRAME_LIST__-1b@l
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
bctrl /* and call the routine */
|
||||
5:
|
||||
lwz %r28,(4*SZREG)(%r1) /* restore registers */
|
||||
lwz %r29,(5*SZREG)(%r1)
|
||||
lwz %r30,(6*SZREG)(%r1)
|
||||
lwz %r31,(7*SZREG)(%r1)
|
||||
addi %r1,%r1,8*SZREG /* adjust stack */
|
||||
lwz %r0,(1*SZREG)(%r1) /* get return addr */
|
||||
mtlr %r0
|
||||
blr /* and return */
|
||||
|
||||
__do_global_ctors_aux:
|
||||
mflr %r7 /* save return address */
|
||||
bcl 20,31,1f /* find out what address */
|
||||
1: mflr %r3 /* we are at */
|
||||
mtlr %r7 /* restore return address */
|
||||
|
||||
addis %r4,%r3,__initialized-1b@ha /* pcrel (hi) */
|
||||
lbzu %r0,__initialized-1b@l(%r4) /* pcrel (lo) load+update */
|
||||
cmpwi %r0,0 /* have we already done this? */
|
||||
bnelr /* yep, return */
|
||||
|
||||
li %r0,1
|
||||
stb %r0,0(%r4) /* remember we've been here */
|
||||
|
||||
stw %r7,(1*SZREG)(%r1) /* save LR */
|
||||
stwu %r1,-(8*SZREG)(%r1) /* alloc our stack frame */
|
||||
stw %r31,(7*SZREG)(%r1) /* save some registers */
|
||||
stw %r30,(6*SZREG)(%r1)
|
||||
stw %r29,(5*SZREG)(%r1)
|
||||
stw %r28,(4*SZREG)(%r1)
|
||||
|
||||
mr %r29,%r3 /* move this to a safe place */
|
||||
|
||||
/*
|
||||
* Get a reference to our TOC.
|
||||
*/
|
||||
addis %r30,%r29,.LCTOC-1b@ha
|
||||
addi %r30,%r30,.LCTOC-1b@l
|
||||
|
||||
/*
|
||||
* Get a reference to the GOT.
|
||||
*/
|
||||
addis %r31,%r29,_GLOBAL_OFFSET_TABLE_-1b@ha /* pcrel (hi) */
|
||||
addi %r31,%r31,_GLOBAL_OFFSET_TABLE_-1b@l /* pcrel (lo) */
|
||||
|
||||
/*
|
||||
* if (__register_frame_info)
|
||||
* __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object)
|
||||
*/
|
||||
lwz %r0, __register_frame_info@got(%r31)
|
||||
cmpwi %r0, 0
|
||||
beq 2f
|
||||
|
||||
addis %r3,%r29,__EH_FRAME_LIST__-1b@ha /* pcrel (hi) */
|
||||
addi %r3,%r3,__EH_FRAME_LIST__-1b@l /* pcrel (lo) */
|
||||
addis %r4,%r29,__dwarf_eh_object-1b@ha /* pcrel (hi) */
|
||||
addi %r4,%r4,__dwarf_eh_object-1b@l /* pcrel (lo) */
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
bctrl /* and call the routine */
|
||||
|
||||
2:
|
||||
/*
|
||||
* if (_Jv_RegisterClasses && __JCR_LIST__[0])
|
||||
* _Jv_RegisterClasses(&__JCR_LIST__[0]);
|
||||
*/
|
||||
lwz %r0, _Jv_RegisterClasses@got(%r31)
|
||||
cmpwi %r0, 0
|
||||
beq 3f
|
||||
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
addis %r3, %r29, __JCR_LIST__-1b@ha /* pcrel (hi) */
|
||||
addi %r3, %r3, __JCR_LIST__-1b@l /* pcrel (lo) */
|
||||
lwz %r4, 0(%r3) /* load first entry */
|
||||
cmpwi %r4, 0 /* is the list empty? */
|
||||
bnectrl /* call the routine if not */
|
||||
3:
|
||||
|
||||
/*
|
||||
* Get end of list of CTOR list.
|
||||
*/
|
||||
addis %r28,%r29,__CTOR_LIST_END__-1b@ha
|
||||
addi %r28,%r28,__CTOR_LIST_END__-1b@l
|
||||
4:
|
||||
lwzu %r0, -4(%r28) /* get entry */
|
||||
cmpwi %r0, -1 /* first entry? */
|
||||
beq 5f /* yes, we're done */
|
||||
mtctr %r0 /* setup for indirect branch */
|
||||
bctrl /* call the routine */
|
||||
b 4b /* do it again */
|
||||
5:
|
||||
lwz %r28,(4*SZREG)(%r1) /* restore registers */
|
||||
lwz %r29,(5*SZREG)(%r1)
|
||||
lwz %r30,(6*SZREG)(%r1)
|
||||
lwz %r31,(7*SZREG)(%r1)
|
||||
addi %r1,%r1,8*SZREG /* adjust stack */
|
||||
lwz %r0,(1*SZREG)(%r1) /* get return addr */
|
||||
mtlr %r0
|
||||
blr /* and return */
|
||||
|
||||
.section .init, "ax", @progbits
|
||||
bl __do_global_ctors_aux
|
||||
.section .fini, "ax", @progbits
|
||||
bl __do_global_dtors_aux
|
|
@ -0,0 +1,36 @@
|
|||
/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
__asm( ".pushsection .init, \"ax\", @progbits"
|
||||
"\n\t" "bl __do_global_ctors_aux"
|
||||
"\n\t" ".popsection");
|
||||
|
||||
__asm( ".pushsection .fini, \"ax\", @progbits"
|
||||
"\n\t" "bl __do_global_dtors_aux"
|
||||
"\n\t" ".popsection");
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $ */
|
||||
/* $NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <powerpc/asm.h>
|
||||
|
||||
RCSID("$NetBSD: crtend.S,v 1.1 2011/02/08 02:02:25 matt Exp $")
|
||||
RCSID("$NetBSD: crtend.S,v 1.2 2013/06/27 21:24:39 matt Exp $")
|
||||
|
||||
.section .ctors, "aw", @progbits
|
||||
.p2align 2
|
||||
|
@ -41,6 +41,9 @@ __CTOR_LIST_END__:
|
|||
|
||||
.section .dtors, "aw", @progbits
|
||||
.p2align 2
|
||||
.global __DTOR_LIST_END__
|
||||
.hidden __DTOR_LIST_END__
|
||||
__DTOR_LIST_END__:
|
||||
.long 0
|
||||
|
||||
.section .eh_frame, "a", @progbits
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
__asm( ".pushsection .init, \"ax\", @progbits" "\n\t"
|
||||
"calls $0, __do_global_ctors_aux" "\n\t"
|
||||
".popsection" "\n\t"
|
||||
".pushsection .fini, \"ax\", @progbits" "\n\t"
|
||||
"calls $0, __do_global_dtors_aux" "\n\t"
|
||||
".popsection"
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.inc,v 1.11 2013/06/27 03:37:21 matt Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.12 2013/06/27 21:24:39 matt Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -19,7 +19,7 @@ crtbegin.o: crtbegin.S
|
|||
.else
|
||||
crtbegin.o: crtbegin.c crtbegin.h
|
||||
${_MKTARGET_COMPILE}
|
||||
${COMPILE.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
|
||||
${COMPILE.c} -fpie ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o
|
||||
.endif
|
||||
${LD} -x -r -o ${.TARGET} ${.TARGET}.o
|
||||
rm -f ${.TARGET}.o
|
||||
|
|
|
@ -27,79 +27,105 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: crtbegin.c,v 1.2 2013/06/24 14:49:13 matt Exp $");
|
||||
__RCSID("$NetBSD: crtbegin.c,v 1.3 2013/06/27 21:24:39 matt Exp $");
|
||||
|
||||
typedef void (*fptr_t)(void);
|
||||
|
||||
__dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr");
|
||||
__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame");
|
||||
|
||||
__weakref_visible void Jv_RegisterClasses(const fptr_t *)
|
||||
__weak_reference(_Jv_RegisterClasses);
|
||||
|
||||
#if !defined(HAVE_INITFINI_ARRAY)
|
||||
__dso_hidden const fptr_t __CTOR_LIST__[] __section(".ctors") = {
|
||||
(fptr_t) -1,
|
||||
};
|
||||
__dso_hidden extern const fptr_t __CTOR_LIST_END__[];
|
||||
__dso_hidden const fptr_t __DTOR_LIST__[] __section(".dtors") = {
|
||||
(fptr_t) -1,
|
||||
};
|
||||
__dso_hidden extern const fptr_t __DTOR_LIST_END__[];
|
||||
#endif
|
||||
|
||||
#ifdef SHARED
|
||||
__dso_hidden void *__dso_handle = &__dso_handle;
|
||||
|
||||
__weakref_visible void cxa_finalize(void *)
|
||||
__weak_reference(__cxa_finalize);
|
||||
#else
|
||||
__dso_hidden void *__dso_handle;
|
||||
#endif
|
||||
|
||||
__weakref_visible void cxa_finalize(void *)
|
||||
__weak_reference(__cxa_finalize);
|
||||
__weakref_visible void Jv_RegisterClasses(const fptr_t *)
|
||||
__weak_reference(_Jv_RegisterClasses);
|
||||
#if !defined(__ARM_EABI__)
|
||||
__dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame");
|
||||
|
||||
__weakref_visible void register_frame_info(const void *, const void *)
|
||||
__weak_reference(__register_frame_info);
|
||||
__weakref_visible void deregister_frame_info(const void *)
|
||||
__weak_reference(__deregister_frame_info);
|
||||
|
||||
static long dwarf_eh_object[8];
|
||||
static unsigned char __initialized;
|
||||
static unsigned char __finished;
|
||||
#endif
|
||||
|
||||
static void __do_global_ctors_aux(void) __used;
|
||||
static void __do_global_dtors_aux(void) __used;
|
||||
|
||||
static void
|
||||
__do_global_ctors_aux(void)
|
||||
{
|
||||
static unsigned char __initialized;
|
||||
|
||||
if (__initialized)
|
||||
return;
|
||||
|
||||
__initialized = 1;
|
||||
|
||||
#if !defined(__ARM_EABI__)
|
||||
if (register_frame_info)
|
||||
register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object);
|
||||
#endif
|
||||
|
||||
if (Jv_RegisterClasses && __JCR_LIST__[0] != 0)
|
||||
Jv_RegisterClasses(__JCR_LIST__);
|
||||
|
||||
#if !defined(HAVE_INITFINI_ARRAY)
|
||||
for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) {
|
||||
(*(*--p))();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(__ARM_EABI__) || defined(SHARED)
|
||||
#if !defined(HAVE_INITFINI_ARRAY)
|
||||
__dso_hidden const fptr_t __DTOR_LIST__[] __section(".dtors") = {
|
||||
(fptr_t) -1,
|
||||
};
|
||||
__dso_hidden extern const fptr_t __DTOR_LIST_END__[];
|
||||
#endif
|
||||
|
||||
static void __do_global_dtors_aux(void) __used;
|
||||
|
||||
static void
|
||||
__do_global_dtors_aux(void)
|
||||
{
|
||||
static unsigned char __finished;
|
||||
|
||||
if (__finished)
|
||||
return;
|
||||
|
||||
__finished = 1;
|
||||
|
||||
#ifdef SHARED
|
||||
if (cxa_finalize)
|
||||
cxa_finalize(__dso_handle);
|
||||
|
||||
(*cxa_finalize)(__dso_handle);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_INITFINI_ARRAY)
|
||||
for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) {
|
||||
(*(*p++))();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__ARM_EABI__)
|
||||
if (deregister_frame_info)
|
||||
deregister_frame_info(__EH_FRAME_LIST__);
|
||||
#endif
|
||||
}
|
||||
#endif /* !__ARM_EABI__ || SHARED */
|
||||
|
||||
#include "crtbegin.h"
|
||||
|
|
Loading…
Reference in New Issue