crtn.asm revision 256281
1258945Sroberto#   Copyright (C) 2001, 2004 Free Software Foundation, Inc.
2258945Sroberto#   Written By Nick Clifton
3258945Sroberto# 
4258945Sroberto# This file is free software; you can redistribute it and/or modify it
5258945Sroberto# under the terms of the GNU General Public License as published by the
6258945Sroberto# Free Software Foundation; either version 2, or (at your option) any
7258945Sroberto# later version.
8258945Sroberto# 
9258945Sroberto# In addition to the permissions in the GNU General Public License, the
10258945Sroberto# Free Software Foundation gives you unlimited permission to link the
11258945Sroberto# compiled version of this file with other programs, and to distribute
12258945Sroberto# those programs without any restriction coming from the use of this
13258945Sroberto# file.  (The General Public License restrictions do apply in other
14258945Sroberto# respects; for example, they cover modification of the file, and
15258945Sroberto# distribution when not linked into another program.)
16258945Sroberto# 
17258945Sroberto# This file is distributed in the hope that it will be useful, but
18258945Sroberto# WITHOUT ANY WARRANTY; without even the implied warranty of
19258945Sroberto# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20258945Sroberto# General Public License for more details.
21258945Sroberto# 
22258945Sroberto# You should have received a copy of the GNU General Public License
23258945Sroberto# along with this program; see the file COPYING.  If not, write to
24258945Sroberto# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
25258945Sroberto# Boston, MA 02110-1301, USA.
26258945Sroberto# 
27258945Sroberto#    As a special exception, if you link this library with files
28258945Sroberto#    compiled with GCC to produce an executable, this does not cause
29258945Sroberto#    the resulting executable to be covered by the GNU General Public License.
30258945Sroberto#    This exception does not however invalidate any other reasons why
31258945Sroberto#    the executable file might be covered by the GNU General Public License.
32258945Sroberto# 
33258945Sroberto
34258945Sroberto# This file just makes sure that the .fini and .init sections do in
35258945Sroberto# fact return.  Users may put any desired instructions in those sections.
36280849Scy# This file is the last thing linked into any executable.
37280849Scy
38280849Scy	# Note - this macro is complemented by the FUNC_START macro
39258945Sroberto	# in crti.asm.  If you change this macro you must also change
40258945Sroberto	# that macro match.
41280849Scy	#
42280849Scy	# Note - we do not try any fancy optimizations of the return
43280849Scy	# sequences here, it is just not worth it.  Instead keep things
44280849Scy	# simple.  Restore all the save resgisters, including the link
45280849Scy	# register and then perform the correct function return instruction.
46280849Scy	# We also save/restore r3 to ensure stack alignment.
47280849Scy.macro FUNC_END
48280849Scy#ifdef __thumb__
49280849Scy	.thumb
50280849Scy	
51280849Scy	pop	{r3, r4, r5, r6, r7}
52280849Scy	pop	{r3}
53280849Scy	mov	lr, r3
54280849Scy#else
55280849Scy	.arm
56280849Scy	
57280849Scy	sub	sp, fp, #40
58280849Scy	ldmfd	sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr}
59280849Scy#endif
60280849Scy	
61280849Scy#if defined __THUMB_INTERWORK__ || defined __thumb__
62280849Scy	bx	lr
63280849Scy#else
64280849Scy	mov	pc, lr
65280849Scy#endif
66280849Scy.endm
67280849Scy		
68280849Scy	
69280849Scy	.file		"crtn.asm"
70280849Scy
71280849Scy	.section	".init"
72280849Scy	;;
73280849Scy	FUNC_END
74280849Scy	
75280849Scy	.section	".fini"
76280849Scy	;;
77280849Scy	FUNC_END
78280849Scy	
79280849Scy# end of crtn.asm
80280849Scy