Home | History | Annotate | Line # | Download | only in nios2
crti.S revision 1.1.1.6
      1  1.1.1.6  mrg /* Copyright (C) 2012-2020 Free Software Foundation, Inc.
      2      1.1  mrg    Contributed by Jonah Graham (jgraham (at) altera.com).
      3      1.1  mrg    Contributed by Mentor Graphics, Inc.
      4      1.1  mrg 
      5      1.1  mrg This file is free software; you can redistribute it and/or modify it
      6      1.1  mrg under the terms of the GNU General Public License as published by the
      7      1.1  mrg Free Software Foundation; either version 3, or (at your option) any
      8      1.1  mrg later version.
      9      1.1  mrg 
     10      1.1  mrg This file is distributed in the hope that it will be useful, but
     11      1.1  mrg WITHOUT ANY WARRANTY; without even the implied warranty of
     12      1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13      1.1  mrg General Public License for more details.
     14      1.1  mrg 
     15      1.1  mrg Under Section 7 of GPL version 3, you are granted additional
     16      1.1  mrg permissions described in the GCC Runtime Library Exception, version
     17      1.1  mrg 3.1, as published by the Free Software Foundation.
     18      1.1  mrg 
     19      1.1  mrg You should have received a copy of the GNU General Public License and
     20      1.1  mrg a copy of the GCC Runtime Library Exception along with this program;
     21      1.1  mrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     22      1.1  mrg <http://www.gnu.org/licenses/>.  */
     23      1.1  mrg 
     24      1.1  mrg 
     25      1.1  mrg /* This file just make a stack frame for the contents of the .fini and
     26      1.1  mrg    .init sections.  Users may put any desired instructions in those
     27      1.1  mrg    sections.
     28      1.1  mrg 
     29      1.1  mrg    While technically any code can be put in the init and fini sections
     30      1.1  mrg    most stuff will not work other than stuff which obeys the call frame
     31      1.1  mrg    and ABI.  All the call-preserved registers are saved, the call clobbered
     32      1.1  mrg    registers should have been saved by the code calling init and fini.
     33      1.1  mrg 
     34      1.1  mrg    See crtstuff.c for an example of code that inserts itself in the init
     35      1.1  mrg    and fini sections.
     36      1.1  mrg 
     37      1.1  mrg    See crt0.s for the code that calls init and fini.  */
     38      1.1  mrg 
     39      1.1  mrg 	.section	".init"
     40      1.1  mrg 	.align 2
     41      1.1  mrg 	.global	_init
     42      1.1  mrg _init:
     43      1.1  mrg 	addi	sp, sp, -48
     44      1.1  mrg 	stw	ra, 44(sp)
     45      1.1  mrg 	stw	r23, 40(sp)
     46      1.1  mrg 	stw	r22, 36(sp)
     47      1.1  mrg 	stw	r21, 32(sp)
     48      1.1  mrg 	stw	r20, 28(sp)
     49      1.1  mrg 	stw	r19, 24(sp)
     50      1.1  mrg 	stw	r18, 20(sp)
     51      1.1  mrg 	stw	r17, 16(sp)
     52      1.1  mrg 	stw	r16, 12(sp)
     53      1.1  mrg 	stw	fp, 8(sp)
     54      1.1  mrg 	addi	fp, sp, 8
     55      1.1  mrg #ifdef linux
     56      1.1  mrg 	nextpc	r22
     57      1.1  mrg 1:	movhi	r2, %hiadj(_gp_got - 1b)
     58      1.1  mrg 	addi	r2, r2, %lo(_gp_got - 1b)
     59      1.1  mrg 	add	r22, r22, r2
     60      1.1  mrg #endif
     61      1.1  mrg 
     62      1.1  mrg 
     63      1.1  mrg 	.section	".fini"
     64      1.1  mrg 	.align	2
     65      1.1  mrg 	.global	_fini
     66      1.1  mrg _fini:
     67      1.1  mrg 	addi	sp, sp, -48
     68      1.1  mrg 	stw	ra, 44(sp)
     69      1.1  mrg 	stw	r23, 40(sp)
     70      1.1  mrg 	stw	r22, 36(sp)
     71      1.1  mrg 	stw	r21, 32(sp)
     72      1.1  mrg 	stw	r20, 28(sp)
     73      1.1  mrg 	stw	r19, 24(sp)
     74      1.1  mrg 	stw	r18, 20(sp)
     75      1.1  mrg 	stw	r17, 16(sp)
     76      1.1  mrg 	stw	r16, 12(sp)
     77      1.1  mrg 	stw	fp, 8(sp)
     78      1.1  mrg 	addi	fp, sp, 8
     79      1.1  mrg #ifdef linux
     80      1.1  mrg 	nextpc	r22
     81      1.1  mrg 1:	movhi	r2, %hiadj(_gp_got - 1b)
     82      1.1  mrg 	addi	r2, r2, %lo(_gp_got - 1b)
     83      1.1  mrg 	add	r22, r22, r2
     84      1.1  mrg #endif
     85      1.1  mrg 
     86