1 /* Startup code for Alpha/ELF.
2 Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Richard Henderson <rth@tamu.edu>
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
23 .globl _start /* what ELF wants */
24 .globl __start /* for backwards (ECOFF) comatibility */
35 /* Save v0. When starting a binary via the dynamic linker, s0
36 contains the address of the shared library termination function,
37 which we will register below with atexit() to be called by exit().
38 If we are statically linked, this will be NULL. */
41 /* Do essential libc initialization (sp points to argc, argv, and envp) */
42 jsr ra, __libc_init_first
45 /* Now that we have the proper stack frame, register library termination
46 function, if there is any: */
54 /* Extract the arguments and environment as encoded on the stack. */
55 ldl a0, 0(sp) /* get argc */
56 lda a1, 8(sp) /* get argv */
57 s8addq a0, a1, a2 /* get envp */
61 mov a0, s0 /* tuck them away */
66 /* Call _init, the entry point to our own .init section. */
70 /* Register our .fini section with atexit. */
75 /* initialize constructors: */
83 /* Call the user's main and exit with its return value. */
90 /* Die very horribly if exit returns. Call_pal hlt is callable from
91 kernel mode only; this will result in an illegal instruction trap. */
95 /* Define a symbol for the first piece of initialized data. */
102 .size __data_start, 4
103 .type __data_start, @object
106 weak_alias(__data_start, data_start)