OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / irix-crti.asm
1 /* Copyright (C) 2004, 2008 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
9
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
22 <http://www.gnu.org/licenses/>.  */
23
24         .abicalls
25         .set    noreorder
26         .set    nomacro
27
28 /* The GNU and SGI linkers differ in their implementation of -init and -fini.
29    With the GNU linker, there can only be a single -init option, and the
30    linker simply sets DT_INIT to that value.  gcc's initialization and
31    finalization code can go directly in .init, with the prologue and
32    epilogue of the main initialization routine being provided by external
33    object files (*crti.o and *crtn.o in this case).
34
35    The SGI linker instead accepts several -init options.  It will set DT_INIT
36    to a linker-created function (placed in .init) that calls each of the -init
37    functions in turn.  If there is any user code in .init, this linker-created
38    function will be placed after it.  Note that such user code is not treated
39    specially; it will only be called if the -init options arrange for it to
40    be called.
41
42    In theory, the SGI model should allow the crti, crtn and intermediate code
43    to go in .init, just like it can with the GNU linker.  However, doing this
44    seems to confuse the linker and triggers an internal error:
45
46       ld32: FATAL   2  : Internal: at ../../ld/mips_code.c mips_code_fixup()
47          text section overflow!
48
49    (seen with MIPSpro 7.30).  We therefore put everything in a special
50    .gcc_init section instead.  */
51
52         .section .gcc_init,"ax",@progbits
53         .globl  __gcc_init
54 __gcc_init:
55 #if _MIPS_SIM == _ABIO32
56         addiu   $sp,$sp,-16
57         sw      $31,0($sp)
58 #else
59         daddiu  $sp,$sp,-16
60         sd      $31,0($sp)
61         sd      $28,8($sp)
62 #endif
63
64         .section .gcc_fini,"ax",@progbits
65         .globl  __gcc_fini
66 __gcc_fini:
67 #if _MIPS_SIM == _ABIO32
68         addiu   $sp,$sp,-16
69         sw      $31,0($sp)
70 #else
71         daddiu  $sp,$sp,-16
72         sd      $31,0($sp)
73         sd      $28,8($sp)
74 #endif
75
76 /* This object will typically be included in the final link for both
77    shared libraries and executable, and we need to hide the symbols to
78    prevent possible symbol preemption warnings from the SGI linker.  */
79 .hidden __gcc_init
80 .hidden __gcc_fini
81