update from main archive 961126
[glibc.git] / sysdeps / alpha / elf / crtbegin.S
blobf75673e35f509a63906a72265d9eb1738b0c112d
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  * Heads of the constructor/destructor lists.
22  */
24 /* The __*TOR_LIST__ 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_LIST__:
32         .quad -1
34 .section .dtors,"aw"
36         .align 3
37 __DTOR_LIST__:
38         .quad -1
42  * Fragment of the ELF _fini routine that invokes our dtor cleanup.
43  */
45 .section .fini,"ax"
47         /* Since the bits of the _fini 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 .fini 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_dtors_aux
57         /* Must match the alignment we got from crti.o else we get
58           zero-filled holes in our _fini function and thense SIGILL.  */
59         .align 3
62  * Invoke our destructors in order.
63  */
65 .text
67         .align 3
68         .ent __do_global_dtors_aux
70 __do_global_dtors_aux:
71         .frame  $sp,16,$26,0
72         /* GP already loaded in .fini */
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,__DTOR_LIST__
80         br      1f
81 0:      jsr     $26,($27)
82 1:      ldq     $27,8($9)
83         addq    $9,8,$9
84         bne     $27,0b
86         ldq     $26,0($sp)
87         ldq     $9,8($sp)
88         lda     $sp,16($sp)
89         ret
91         .end __do_global_dtors_aux