OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / ldso / ldso / microblaze / dl-startup.h
1 /* Startup code for the microblaze platform, based on glibc 2.3.6, dl-machine.h */
2
3 /*
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 __asm__ ("\
19         .text\n\
20         .globl _start\n\
21         .type _start,@function\n\
22         .hidden _start\n\
23 _start:\n\
24         addk  r5,r0,r1\n\
25         addk  r3,r0,r0\n\
26 1:\n\
27         addik r5,r5,4\n\
28         lw    r4,r5,r0\n\
29         bneid r4,1b\n\
30         addik r3,r3,1\n\
31         addik r3,r3,-1\n\
32         addk  r5,r0,r1\n\
33         sw    r3,r5,r0\n\
34         addik r1,r1,-24\n\
35         sw    r15,r1,r0\n\
36         brlid r15,_dl_start\n\
37         nop\n\
38         /* FALLTHRU */\n\
39 \n\
40         .globl _dl_start_user\n\
41         .type _dl_start_user,@function\n\
42 _dl_start_user:\n\
43         mfs   r20,rpc\n\
44         addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n\
45         lwi   r4,r20,_dl_skip_args@GOTOFF\n\
46         lwi   r5,r1,24\n\
47         rsubk r5,r4,r5\n\
48         addk  r4,r4,r4\n\
49         addk  r4,r4,r4\n\
50         addk  r1,r1,r4\n\
51         swi   r5,r1,24\n\
52         swi   r3,r1,20\n\
53         addk  r6,r5,r0\n\
54         addk  r5,r5,r5\n\
55         addk  r5,r5,r5\n\
56         addik r7,r1,28\n\
57         addk  r8,r7,r5\n\
58         addik r8,r8,4\n\
59         lwi   r5,r1,24\n\
60         lwi   r3,r1,20\n\
61         addk  r4,r5,r5\n\
62         addk  r4,r4,r4\n\
63         addik r6,r1,28\n\
64         addk  r7,r6,r4\n\
65         addik r7,r7,4\n\
66         addik r15,r20,_dl_fini@GOTOFF\n\
67         addik r15,r15,-8\n\
68         brad  r3\n\
69         addik r1,r1,24\n\
70         nop\n\
71         .size _dl_start_user, . - _dl_start_user\n\
72         .previous");
73
74 /*
75  * Get a pointer to the argv array.  On many platforms this can be just
76  * the address of the first argument, on other platforms we need to
77  * do something a little more subtle here.
78  */
79 #define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
80
81 /* The ld.so library requires relocations */
82 #define ARCH_NEEDS_BOOTSTRAP_RELOCS
83
84 static __always_inline
85 void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
86         unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
87 {
88
89         switch (ELF_R_TYPE(rpnt->r_info))
90         {
91                 case R_MICROBLAZE_REL:
92
93                         *reloc_addr = load_addr + rpnt->r_addend;
94                         break;
95
96                 default:
97                         _dl_exit(1);
98                         break;
99
100         }
101
102 }