1 1.1 joerg /* $NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */ 2 1.1 joerg /*- 3 1.1 joerg * Copyright (c) 2010 Joerg Sonnenberger <joerg (at) NetBSD.org> 4 1.1 joerg * All rights reserved. 5 1.1 joerg * 6 1.1 joerg * Redistribution and use in source and binary forms, with or without 7 1.1 joerg * modification, are permitted provided that the following conditions 8 1.1 joerg * are met: 9 1.1 joerg * 10 1.1 joerg * 1. Redistributions of source code must retain the above copyright 11 1.1 joerg * notice, this list of conditions and the following disclaimer. 12 1.1 joerg * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 joerg * notice, this list of conditions and the following disclaimer in 14 1.1 joerg * the documentation and/or other materials provided with the 15 1.1 joerg * distribution. 16 1.1 joerg * 17 1.1 joerg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 1.1 joerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 1.1 joerg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 1.1 joerg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 1.1 joerg * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 1.1 joerg * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 1.1 joerg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 1.1 joerg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 1.1 joerg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 1.1 joerg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 27 1.1 joerg * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 1.1 joerg * SUCH DAMAGE. 29 1.1 joerg */ 30 1.1 joerg 31 1.1 joerg #include <machine/asm.h> 32 1.1 joerg 33 1.1 joerg RCSID("$NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:33 joerg Exp $") 34 1.1 joerg 35 1.1 joerg .section .ctors, "aw", @progbits 36 1.1 joerg .align 4 37 1.1 joerg __CTOR_LIST__: 38 1.1 joerg .long -1 39 1.1 joerg 40 1.1 joerg .section .dtors, "aw", @progbits 41 1.1 joerg .align 4 42 1.1 joerg __DTOR_LIST__: 43 1.1 joerg .long -1 44 1.1 joerg 45 1.1 joerg .section .eh_frame, "a", @progbits 46 1.1 joerg .align 4 47 1.1 joerg __EH_FRAME_LIST__: 48 1.1 joerg 49 1.1 joerg .section .jcr, "aw", @progbits 50 1.1 joerg .align 4 51 1.1 joerg __JCR_LIST__: 52 1.1 joerg 53 1.1 joerg .section .data.rel, "aw", @progbits 54 1.1 joerg .align 4 55 1.1 joerg .type __dso_handle, @object 56 1.1 joerg .size __dso_handle, 4 57 1.1 joerg .globl __dso_handle 58 1.1 joerg .hidden __dso_handle 59 1.1 joerg __dso_handle: 60 1.1 joerg #ifdef SHARED 61 1.1 joerg .long __dso_handle 62 1.1 joerg #else 63 1.1 joerg .long 0 64 1.1 joerg #endif 65 1.1 joerg 66 1.1 joerg __dwarf_eh_object: 67 1.1 joerg .zero 32 68 1.1 joerg 69 1.1 joerg __initialized: 70 1.1 joerg .zero 1 71 1.1 joerg __finished: 72 1.1 joerg .zero 1 73 1.1 joerg 74 1.1 joerg .text 75 1.1 joerg .weak __cxa_finalize 76 1.1 joerg .weak __deregister_frame_info 77 1.1 joerg .weak __register_frame_info 78 1.1 joerg .weak _Jv_RegisterClasses 79 1.1 joerg 80 1.1 joerg __get_thunk: 81 1.1 joerg movl (%esp), %ebx 82 1.1 joerg ret 83 1.1 joerg 84 1.1 joerg __do_global_dtors_aux: 85 1.1 joerg pushl %ebx 86 1.1 joerg pushl %edi 87 1.1 joerg subl $8, %esp 88 1.1 joerg call __get_thunk 89 1.1 joerg addl $_GLOBAL_OFFSET_TABLE_, %ebx 90 1.1 joerg 91 1.1 joerg cmpb $0, __finished@GOTOFF(%ebx) 92 1.1 joerg jne 4f 93 1.1 joerg movb $1, __finished@GOTOFF(%ebx) 94 1.1 joerg 95 1.1 joerg #ifdef SHARED 96 1.1 joerg cmpl $0, __cxa_finalize@GOT(%ebx) 97 1.1 joerg je 1f 98 1.1 joerg movl __dso_handle@GOTOFF(%ebx), %eax 99 1.1 joerg movl %eax, (%esp) 100 1.1 joerg call __cxa_finalize@PLT 101 1.1 joerg 1: 102 1.1 joerg #endif 103 1.1 joerg 104 1.1 joerg leal 4+__DTOR_LIST__@GOTOFF(%ebx), %edi 105 1.1 joerg 2: 106 1.1 joerg movl (%edi), %eax 107 1.1 joerg testl %eax, %eax 108 1.1 joerg je 3f 109 1.1 joerg call *%eax 110 1.1 joerg addl $8, %edi 111 1.1 joerg jmp 2b 112 1.1 joerg 3: 113 1.1 joerg 114 1.1 joerg cmpl $0, __deregister_frame_info@GOT(%ebx) 115 1.1 joerg je 4f 116 1.1 joerg leal __EH_FRAME_LIST__@GOTOFF(%ebx), %eax 117 1.1 joerg movl %eax, (%esp) 118 1.1 joerg call __deregister_frame_info@PLT 119 1.1 joerg 4: 120 1.1 joerg addl $8, %esp 121 1.1 joerg popl %edi 122 1.1 joerg popl %ebx 123 1.1 joerg ret 124 1.1 joerg 125 1.1 joerg 126 1.1 joerg __do_global_ctors_aux: 127 1.1 joerg pushl %ebx 128 1.1 joerg pushl %edi 129 1.1 joerg subl $8, %esp 130 1.1 joerg call __get_thunk 131 1.1 joerg addl $_GLOBAL_OFFSET_TABLE_, %ebx 132 1.1 joerg 133 1.1 joerg cmpb $0, __initialized@GOTOFF(%ebx) 134 1.1 joerg jne 4f 135 1.1 joerg movb $1, __initialized@GOTOFF(%ebx) 136 1.1 joerg 137 1.1 joerg cmpl $0, __register_frame_info@GOT(%ebx) 138 1.1 joerg je 1f 139 1.1 joerg leal __dwarf_eh_object@GOTOFF(%ebx), %edi 140 1.1 joerg movl %edi, 4(%esp) 141 1.1 joerg leal __EH_FRAME_LIST__@GOTOFF(%ebx), %edi 142 1.1 joerg movl %edi, (%esp) 143 1.1 joerg call __register_frame_info@PLT 144 1.1 joerg 145 1.1 joerg 1: 146 1.1 joerg cmpl $0, _Jv_RegisterClasses@GOT(%ebx) 147 1.1 joerg je 2f 148 1.1 joerg leal __JCR_LIST__@GOTOFF(%ebx), %edi 149 1.1 joerg movl (%edi), %edi 150 1.1 joerg testl %edi, %edi 151 1.1 joerg je 2f 152 1.1 joerg movl %edi, (%esp) 153 1.1 joerg call _Jv_RegisterClasses@PLT 154 1.1 joerg 2: 155 1.1 joerg 156 1.1 joerg leal -4+__CTOR_LIST_END__@GOTOFF(%ebx), %edi 157 1.1 joerg 3: 158 1.1 joerg movl (%edi), %eax 159 1.1 joerg cmpl $-1, %eax 160 1.1 joerg je 4f 161 1.1 joerg call *%eax 162 1.1 joerg subl $4, %edi 163 1.1 joerg jmp 3b 164 1.1 joerg 165 1.1 joerg 4: 166 1.1 joerg addl $8, %esp 167 1.1 joerg popl %edi 168 1.1 joerg popl %ebx 169 1.1 joerg ret 170 1.1 joerg 171 1.1 joerg .section .init, "ax", @progbits 172 1.1 joerg call __do_global_ctors_aux 173 1.1 joerg .section .fini, "ax", @progbits 174 1.1 joerg call __do_global_dtors_aux 175