update from main archive 961126
[glibc.git] / sysdeps / alpha / elf / crtend.S
blob7f51d81da1fec4574b6087ace970de4872741b55
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2    Contributed by Richard Henderson (rth@tamu.edu)
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU C Library; see the file COPYING.LIB.  If
16    not, write to the Free Software Foundation, Inc.,
17    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21  * Tails of the constructor/destructor lists.
22  */
24 /* The __*TOR_END__ symbols are not global because when this file is used
25    in a shared library, we do not want the symbol to fall over to the
26    application's lists.  */
28 .section .ctors,"aw"
30         .align 3
31 __CTOR_END__:
32         .quad   0
34 .section .dtors,"aw"
36         .align 3
37 __DTOR_END__:
38         .quad   0
42  * Fragment of the ELF _init routine that invokes our ctor startup
43  */
45 .section .init,"ax"
47         /* Since the bits of the _init function are spread across many
48            object files, each potentially with its own GP, we must
49            assume we need to load ours.  Further, our .init section
50            can easily be more than 4MB away from our .text bits so we
51            can't use bsr.  */
53         br      $gp,1f
54 1:      ldgp    $gp,0($gp)
55         jsr     $26,__do_global_ctors_aux
57         /* Must match the alignment we got from crti.o else we get
58            zero-filled holes in our _init function and thense SIGILL.  */
59         .align 3
62  * Invoke our destructors in order.
63  */
65 .text
67         .align 3
68         .ent __do_global_ctors_aux
70 __do_global_ctors_aux:
71         .frame  $sp,16,$26,0
72         /* GP already loaded in .init.  */
73         lda     $sp,-16($sp)
74         stq     $9,8($sp)
75         stq     $26,0($sp)
76         .mask   (1<<26)|(1<<9), -16
77         .prologue 1
79         lda     $9,__CTOR_END__
80         br      1f
81 0:      jsr     $26,($27)
82 1:      ldq     $27,-8($9)
83         subq    $9,8,$9
84         not     $27,$0
85         bne     $0,0b
87         ldq     $26,0($sp)
88         ldq     $9,8($sp)
89         lda     $sp,16($sp)
90         ret
92         .end __do_global_ctors_aux