OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [i386/] [sol2-c1.asm] - Blame information for rev 282

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
! crt1.s for Solaris 2, x86
2
 
3
!   Copyright (C) 1993, 1998, 2008, 2009 Free Software Foundation, Inc.
4
!   Written By Fred Fish, Nov 1992
5
!
6
! This file is free software; you can redistribute it and/or modify it
7
! under the terms of the GNU General Public License as published by the
8
! Free Software Foundation; either version 3, or (at your option) any
9
! later version.
10
!
11
! This file is distributed in the hope that it will be useful, but
12
! WITHOUT ANY WARRANTY; without even the implied warranty of
13
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
! General Public License for more details.
15
!
16
! Under Section 7 of GPL version 3, you are granted additional
17
! permissions described in the GCC Runtime Library Exception, version
18
! 3.1, as published by the Free Software Foundation.
19
!
20
! You should have received a copy of the GNU General Public License and
21
! a copy of the GCC Runtime Library Exception along with this program;
22
! see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
! .
24
 
25
 
26
! This file takes control of the process from the kernel, as specified
27
! in section 3 of the System V Application Binary Interface, Intel386
28
! Processor Supplement.  It has been constructed from information obtained
29
! from the ABI, information obtained from single stepping existing
30
! Solaris executables through their startup code with gdb, and from
31
! information obtained by single stepping executables on other i386 SVR4
32
! implementations.  This file is the first thing linked into any executable.
33
 
34
        .ident  "GNU C crt1.s"
35
        .weak   _cleanup
36
        .weak   _DYNAMIC
37
        .text
38
 
39
! Start creating the initial frame by pushing a NULL value for the return
40
! address of the initial frame, and mark the end of the stack frame chain
41
! (the innermost stack frame) with a NULL value, per page 3-32 of the ABI.
42
! Initialize the first stack frame pointer in %ebp (the contents of which
43
! are unspecified at process initialization).
44
 
45
        .globl  _start
46
_start:
47
        pushl   $0x0
48
        pushl   $0x0
49
        movl    %esp,%ebp
50
 
51
! As specified per page 3-32 of the ABI, %edx contains a function
52
! pointer that should be registered with atexit(), for proper
53
! shared object termination.  Just push it onto the stack for now
54
! to preserve it.  We want to register _cleanup() first.
55
 
56
        pushl   %edx
57
 
58
! Check to see if there is an _cleanup() function linked in, and if
59
! so, register it with atexit() as the last thing to be run by
60
! atexit().
61
 
62
        movl    $_cleanup,%eax
63
        testl   %eax,%eax
64
        je      .L1
65
        pushl   $_cleanup
66
        call    atexit
67
        addl    $0x4,%esp
68
.L1:
69
 
70
! Now check to see if we have an _DYNAMIC table, and if so then
71
! we need to register the function pointer previously in %edx, but
72
! now conveniently saved on the stack as the argument to pass to
73
! atexit().
74
 
75
        movl    $_DYNAMIC,%eax
76
        testl   %eax,%eax
77
        je      .L2
78
        call    atexit
79
.L2:
80
 
81
! Register _fini() with atexit().  We will take care of calling _init()
82
! directly.
83
 
84
        pushl   $_fini
85
        call    atexit
86
 
87
! Compute the address of the environment vector on the stack and load
88
! it into the global variable _environ.  Currently argc is at 8 off
89
! the frame pointer.  Fetch the argument count into %eax, scale by the
90
! size of each arg (4 bytes) and compute the address of the environment
91
! vector which is 16 bytes (the two zero words we pushed, plus argc,
92
! plus the null word terminating the arg vector) further up the stack,
93
! off the frame pointer (whew!).
94
 
95
        movl    8(%ebp),%eax
96
        leal    16(%ebp,%eax,4),%edx
97
        movl    %edx,_environ
98
 
99
! Push the environment vector pointer, the argument vector pointer,
100
! and the argument count on to the stack to set up the arguments
101
! for _init(), _fpstart(), and main().  Note that the environment
102
! vector pointer and the arg count were previously loaded into
103
! %edx and %eax respectively.  The only new value we need to compute
104
! is the argument vector pointer, which is at a fixed address off
105
! the initial frame pointer.
106
 
107
!
108
! Make sure the stack is properly aligned.
109
!
110
        andl $0xfffffff0,%esp
111
        subl $4,%esp
112
 
113
        pushl   %edx
114
        leal    12(%ebp),%edx
115
        pushl   %edx
116
        pushl   %eax
117
 
118
! Call _init(argc, argv, environ), _fpstart(argc, argv, environ), and
119
! main(argc, argv, environ).
120
 
121
        call    _init
122
        call    __fpstart
123
        call    main
124
 
125
! Pop the argc, argv, and environ arguments off the stack, push the
126
! value returned from main(), and call exit().
127
 
128
        addl    $12,%esp
129
        pushl   %eax
130
        call    exit
131
 
132
! An inline equivalent of _exit, as specified in Figure 3-26 of the ABI.
133
 
134
        pushl   $0x0
135
        movl    $0x1,%eax
136
        lcall   $7,$0
137
 
138
! If all else fails, just try a halt!
139
 
140
        hlt
141
        .type   _start,@function
142
        .size   _start,.-_start
143
 
144
! A dummy profiling support routine for non-profiling executables,
145
! in case we link in some objects that have been compiled for profiling.
146
 
147
        .weak   _mcount
148
_mcount:
149
        ret
150
        .type   _mcount,@function
151
        .size   _mcount,.-_mcount

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.