fstatat: add wrapper that uses statx for non-legacy arch
[uclibc-ng.git] / libc / sysdeps / linux / nios2 / crt1.S
blobe13d59599d5e26100b5ee33853409b2a88995767
1 /* Startup code for Nios II
2    Copyright (C) 1995-2016 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    In addition to the permissions in the GNU Lesser General Public
11    License, the Free Software Foundation gives you unlimited
12    permission to link the compiled version of this file with other
13    programs, and to distribute those programs without any restriction
14    coming from the use of this file. (The GNU Lesser General Public
15    License restrictions do apply in other respects; for example, they
16    cover modification of the file, and distribution when not linked
17    into another program.)
19    Note that people who make modified versions of this file are not
20    obligated to grant this special exception for their modified
21    versions; it is their choice whether to do so. The GNU Lesser
22    General Public License gives permission to release a modified
23    version without this exception; this exception also makes it
24    possible to release a modified version which carries forward this
25    exception.
27    The GNU C Library is distributed in the hope that it will be useful,
28    but WITHOUT ANY WARRANTY; without even the implied warranty of
29    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30    Lesser General Public License for more details.
32    You should have received a copy of the GNU Lesser General Public
33    License along with the GNU C Library.  If not, see
34    <http://www.gnu.org/licenses/>.  */
36 #include <features.h>
37 #include <asm/unistd.h>
39     .global _start
40     .type   _start,@function
41     .type       _init,%function
42     .type       _fini,%function
43 #ifndef __UCLIBC_CTOR_DTOR__
44     .weak   _init
45     .weak   _fini
46 #endif
47     .type   main,@function
48     .type   __uClibc_main,@function
49     .text
51 _start:
52         /* Set up the global pointer.  */
53         movhi   gp, %hiadj(_gp)
54         addi    gp, gp, %lo(_gp)
56         /* Save the stack pointer.  */
57         mov     r2, sp
59         /* Create room on the stack for the fini, rtld_fini and stack_end args
60            to __uClibc_main. */
61         subi    sp, sp, 12
63         /* Push stack_end */
64         stw     r2, 8(sp)
66         /* Push rtld_fini */
67         stw     r4, 4(sp)
69         /* Set up the GOT pointer.  */
70         nextpc  r22
71 1:      movhi   r2, %hiadj(_gp_got - 1b)
72         addi    r2, r2, %lo(_gp_got - 1b)
73         add     r22, r22, r2
75         /* r6 == argv */
76         addi    r6, sp, 16
78         /* r5 == argc */
79         ldw     r5, 12(sp)
81         /* r4 == main */
82         movhi   r4, %call_hiadj(main)
83         addi    r4, r4, %call_lo(main)
84         add     r4, r4, r22
85         ldw     r4, 0(r4)
87         /* fp == 0 */
88         mov     fp, zero
90         /* Let the libc call main and exit with its return code.  */
91         movhi   r2, %call_hiadj(__uClibc_main)
92         addi    r2, r2, %call_lo(__uClibc_main)
93         add     r2, r2, r22
94         ldw     r2, 0(r2)
95         callr   r2
97         /* should never get here....*/
98         movhi   r2, %call_hiadj(abort)
99         addi    r2, r2, %call_lo(abort)
100         add     r2, r2, r22
101         ldw     r2, 0(r2)
102         callr   r2
104 /* Define a symbol for the first piece of initialized data.  */
105         .data
106         .globl __data_start
107 __data_start:
108         .long 0
109         .weak data_start
110         data_start = __data_start