1169689Skan/* Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. 290075Sobrien Contributed by Jes Sorensen, <Jes.Sorensen@cern.ch> 390075Sobrien 4169689Skan This file is part of GCC. 590075Sobrien 6169689Skan GCC is free software; you can redistribute it and/or modify 7169689Skan it under the terms of the GNU General Public License as published by 8169689Skan the Free Software Foundation; either version 2, or (at your option) 9169689Skan any later version. 10169689Skan 11169689Skan GCC is distributed in the hope that it will be useful, 1290075Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 13169689Skan MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14169689Skan GNU General Public License for more details. 1590075Sobrien 16169689Skan You should have received a copy of the GNU General Public License 17169689Skan along with GCC; see the file COPYING. If not, write to 18169689Skan the Free Software Foundation, 51 Franklin Street, Fifth Floor, 19169689Skan Boston, MA 02110-1301, USA. */ 2090075Sobrien 21169689Skan/* As a special exception, if you link this library with other files, 22169689Skan some of which are compiled with GCC, to produce an executable, 23169689Skan this library does not by itself cause the resulting executable 24169689Skan to be covered by the GNU General Public License. 25169689Skan This exception does not however invalidate any other reasons why 26169689Skan the executable file might be covered by the GNU General Public License. */ 27169689Skan 28117395Skan#include "auto-host.h" 29117395Skan 3090075Sobrien.section .ctors,"aw","progbits" 3190075Sobrien .align 8 3290075Sobrien__CTOR_END__: 3390075Sobrien data8 0 3490075Sobrien 3590075Sobrien.section .dtors,"aw","progbits" 3690075Sobrien .align 8 3790075Sobrien__DTOR_END__: 3890075Sobrien data8 0 3990075Sobrien 4090075Sobrien.section .jcr,"aw","progbits" 4190075Sobrien .align 8 4290075Sobrien__JCR_END__: 4390075Sobrien data8 0 4490075Sobrien 45132718Skan#ifdef HAVE_INITFINI_ARRAY 46132718Skan .global __do_global_ctors_aux 47132718Skan .hidden __do_global_ctors_aux 48132718Skan#else /* !HAVE_INITFINI_ARRAY */ 4990075Sobrien/* 5090075Sobrien * Fragment of the ELF _init routine that invokes our dtor cleanup. 5190075Sobrien * 5290075Sobrien * We make the call by indirection, because in large programs the 5390075Sobrien * .fini and .init sections are not in range of the destination, and 5490075Sobrien * we cannot allow the linker to insert a stub at the end of this 5590075Sobrien * fragment of the _fini function. Further, Itanium does not implement 5690075Sobrien * the long branch instructions, and we do not wish every program to 5790075Sobrien * trap to the kernel for emulation. 5890075Sobrien * 5990075Sobrien * Note that we require __do_global_ctors_aux to preserve the GP, 6090075Sobrien * so that the next fragment in .fini gets the right value. 6190075Sobrien */ 6290075Sobrien.section .init,"ax","progbits" 6390075Sobrien { .mlx 64132718Skan movl r2 = @pcrel(__do_global_ctors_aux - 16) 6590075Sobrien } 6690075Sobrien { .mii 6790075Sobrien mov r3 = ip 6890075Sobrien ;; 6990075Sobrien add r2 = r2, r3 7090075Sobrien ;; 7190075Sobrien } 7290075Sobrien { .mib 7390075Sobrien mov b6 = r2 7490075Sobrien br.call.sptk.many b0 = b6 7590075Sobrien ;; 7690075Sobrien } 77117395Skan#endif /* !HAVE_INITFINI_ARRAY */ 7890075Sobrien 7990075Sobrien.text 80132718Skan .align 32 81132718Skan .proc __do_global_ctors_aux 8290075Sobrien__do_global_ctors_aux: 83132718Skan .prologue 8490075Sobrien /* 8590075Sobrien for (loc0 = __CTOR_END__-1; *p != -1; --p) 8690075Sobrien (*p) (); 8790075Sobrien */ 88132718Skan .save ar.pfs, r34 89132718Skan alloc loc2 = ar.pfs, 0, 5, 0, 0 90132718Skan movl loc0 = @gprel(__CTOR_END__ - 8) 91132718Skan ;; 92132718Skan 93132718Skan add loc0 = loc0, gp 94132718Skan ;; 95132718Skan ld8 loc3 = [loc0], -8 96132718Skan .save rp, loc1 97132718Skan mov loc1 = rp 98132718Skan .body 99132718Skan ;; 100132718Skan 101132718Skan cmp.eq p6, p0 = -1, loc3 102132718Skan mov loc4 = gp 103132718Skan(p6) br.cond.spnt.few .exit 104132718Skan 105132718Skan.loop: ld8 r15 = [loc3], 8 106132718Skan ;; 107132718Skan ld8 gp = [loc3] 108132718Skan mov b6 = r15 109132718Skan 110132718Skan ld8 loc3 = [loc0], -8 111132718Skan nop 0 112132718Skan br.call.sptk.many rp = b6 113132718Skan ;; 114132718Skan 115132718Skan cmp.ne p6, p0 = -1, loc3 116132718Skan nop 0 117132718Skan(p6) br.cond.sptk.few .loop 118132718Skan 119132718Skan.exit: mov gp = loc3 120132718Skan mov rp = loc1 121132718Skan mov ar.pfs = loc2 122132718Skan 123132718Skan br.ret.sptk.many rp 124132718Skan .endp __do_global_ctors_aux 125