]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/ldso/ldso/sparc/dl-startup.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / ldso / ldso / sparc / dl-startup.h
1 /* Any assembly language/system dependent hacks needed to setup boot1.c so it
2  * will work as expected and cope with whatever platform specific wierdness is
3  * needed for this architecture.  See arm/boot1_arch.h for an example of what
4  * can be done.
5  */
6
7 __asm__ ("\
8         .text\n\
9         .global _start\n\
10         .type   _start,%function\n\
11         .hidden _start\n\
12         .align 32\n\
13         .register %g2, #scratch\n\
14 _start:\n\
15         /* Allocate space for functions to drop their arguments. */\n\
16         sub     %sp, 6*4, %sp\n\
17         /* Pass pointer to argument block to _dl_start. */\n\
18         call _dl_start\n\
19         add    %sp, 22*4, %o0\n\
20         /* FALTHRU */\n\
21         .globl  _dl_start_user\n\
22         .type   _dl_start_user, @function\n\
23 _dl_start_user:\n\
24   /* Load the PIC register.  */\n\
25 1:      call    2f\n\
26         sethi  %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n\
27 2:      or  %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n\
28         add %l7, %o7, %l7\n\
29   /* Save the user entry point address in %l0 */\n\
30         mov %o0, %l0\n\
31   /* See if we were run as a command with the executable file name as an\n\
32          extra leading argument.  If so, adjust the contents of the stack.  */\n\
33         sethi   %hi(_dl_skip_args), %g2\n\
34         or  %g2, %lo(_dl_skip_args), %g2\n\
35         ld  [%l7+%g2], %i0\n\
36         ld  [%i0], %i0\n\
37         tst %i0\n\
38   /* Pass our finalizer function to the user in %g1.  */\n\
39         sethi   %hi(_dl_fini), %g1\n\
40         or      %g1, %lo(_dl_fini), %g1\n\
41         ld      [%l7+%g1], %g1\n\
42   /* Jump to the user's entry point and deallocate the extra stack we got.  */\n\
43         jmp %l0\n\
44          add    %sp, 6*4, %sp\n\
45         .size   _dl_start_user, . - _dl_start_user\n\
46         .previous\n\
47 ");
48
49 /*
50  * Get a pointer to the argv array.  On many platforms this can be just
51  * the address of the first argument, on other platforms we need to
52  * do something a little more subtle here.  We assume that argc is stored
53  * at the word just below the argvp that we return here.
54  */
55 #define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS) + 1)
56
57 /*
58  * Here is a macro to perform a relocation.  This is only used when
59  * bootstrapping the dynamic loader.
60  */
61 #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
62 switch(ELF_R_TYPE((RELP)->r_info)) { \
63         case R_SPARC_32: \
64         case R_SPARC_GLOB_DAT: \
65                 *REL = SYMBOL + (RELP)->r_addend; \
66                 break; \
67         case R_SPARC_JMP_SLOT: \
68                 REL[1] = 0x03000000 | ((SYMBOL >> 10) & 0x3fffff); \
69                 REL[2] = 0x81c06000 | (SYMBOL & 0x3ff); \
70                 break; \
71         case R_SPARC_NONE: \
72         case R_SPARC_WDISP30: \
73                 break; \
74         case R_SPARC_RELATIVE: \
75                 *REL += (unsigned int) LOAD + (RELP)->r_addend; \
76                 break; \
77         default: \
78                 _dl_exit(1); \
79 }