OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [ldso/] [ldso/] [mips/] [ld_sysdep.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* vi: set sw=4 ts=4: */
2
 
3
/*
4
 * Various assmbly language/system dependent hacks that are required
5
 * so that we can minimize the amount of platform specific code.
6
 */
7
 
8
/*
9
 * Define this if the system uses RELOCA.
10
 */
11
#undef ELF_USES_RELOCA
12
 
13
 
14
/*
15
 * Get a pointer to the argv array.  On many platforms this can be just
16
 * the address if the first argument, on other platforms we need to
17
 * do something a little more subtle here.
18
 */
19
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
20
 
21
 
22
/*
23
 * Initialization sequence for the application/library GOT.
24
 */
25
#define INIT_GOT(GOT_BASE,MODULE)                                                                               \
26
do {                                                                                                                                    \
27
        unsigned long i;                                                                                                        \
28
                                                                                                                                                \
29
        /* Check if this is the dynamic linker itself */                                        \
30
        if (MODULE->libtype == program_interpreter)                                                     \
31
                continue;                                                                                                               \
32
                                                                                                                                                \
33
        /* Fill in first two GOT entries according to the ABI */                        \
34
        GOT_BASE[0] = (unsigned long) _dl_linux_resolve;                                 \
35
        GOT_BASE[1] = (unsigned long) MODULE;                                                           \
36
                                                                                                                                                \
37
        /* Add load address displacement to all local GOT entries */            \
38
        i = 2;                                                                                                                          \
39
        while (i < MODULE->mips_local_gotno)                                                            \
40
                GOT_BASE[i++] += (unsigned long) MODULE->loadaddr;                              \
41
                                                                                                                                                \
42
} while (0)
43
 
44
 
45
/*
46
 * Here is a macro to perform the GOT relocation. This is only
47
 * used when bootstrapping the dynamic loader.
48
 */
49
#define PERFORM_BOOTSTRAP_GOT(got)                                                                              \
50
do {                                                                                                                                    \
51
        Elf32_Sym *sym;                                                                                                         \
52
        unsigned long i;                                                                                                        \
53
                                                                                                                                                \
54
        /* Add load address displacement to all local GOT entries */            \
55
        i = 2;                                                                                                                          \
56
        while (i < tpnt->mips_local_gotno)                                                                      \
57
                got[i++] += load_addr;                                                                                  \
58
                                                                                                                                                \
59
        /* Handle global GOT entries */                                                                         \
60
        got += tpnt->mips_local_gotno;                                                                          \
61
        sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +                            \
62
                 load_addr) + tpnt->mips_gotsym;                                                                \
63
        i = tpnt->mips_symtabno - tpnt->mips_gotsym;                                            \
64
                                                                                                                                                \
65
        while (i--) {                                                                                                           \
66
                if (sym->st_shndx == SHN_UNDEF ||                                                               \
67
                        sym->st_shndx == SHN_COMMON)                                                            \
68
                        *got = load_addr + sym->st_value;                                                       \
69
                else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&                             \
70
                        *got != sym->st_value)                                                                          \
71
                        *got += load_addr;                                                                                      \
72
                else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {                  \
73
                        if (sym->st_other == 0)                                                                          \
74
                                *got += load_addr;                                                                              \
75
                }                                                                                                                               \
76
                else                                                                                                                    \
77
                        *got = load_addr + sym->st_value;                                                       \
78
                                                                                                                                                \
79
                got++;                                                                                                                  \
80
                sym++;                                                                                                                  \
81
        }                                                                                                                                       \
82
} while (0)
83
 
84
 
85
/*
86
 * Here is a macro to perform a relocation.  This is only used when
87
 * bootstrapping the dynamic loader.
88
 */
89
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)                    \
90
        switch(ELF32_R_TYPE((RELP)->r_info)) {                                                          \
91
        case R_MIPS_REL32:                                                                                                      \
92
                if (symtab_index) {                                                                                             \
93
                        if (symtab_index < tpnt->mips_gotsym)                                           \
94
                                *REL += SYMBOL;                                                                                 \
95
                }                                                                                                                               \
96
                else {                                                                                                                  \
97
                        *REL += LOAD;                                                                                           \
98
                }                                                                                                                               \
99
                break;                                                                                                                  \
100
        case R_MIPS_NONE:                                                                                                       \
101
                break;                                                                                                                  \
102
        default:                                                                                                                        \
103
                SEND_STDERR("Aiieeee!");                                                                                \
104
                _dl_exit(1);                                                                                                    \
105
        }
106
 
107
 
108
/*
109
 * Transfer control to the user's application, once the dynamic loader
110
 * is done.  This routine has to exit the current function, then
111
 * call the _dl_elf_main function. For MIPS, we do it in assembly
112
 * because the stack doesn't get properly restored otherwise. Got look
113
 * at boot1_arch.h
114
 */
115
#define START()
116
 
117
 
118
/* Here we define the magic numbers that this dynamic loader should accept */
119
#define MAGIC1 EM_MIPS
120
#define MAGIC2 EM_MIPS_RS3_LE
121
 
122
 
123
/* Used for error messages */
124
#define ELF_TARGET "MIPS"
125
 
126
 
127
unsigned long _dl_linux_resolver(unsigned long sym_index,
128
        unsigned long old_gpreg);
129
 
130
 
131
#define do_rem(result, n, base)  result = (n % base)
132
 
133
/* 4096 bytes alignment */
134
#define PAGE_ALIGN 0xfffff000
135
#define ADDR_ALIGN 0xfff
136
#define OFFS_ALIGN 0x7ffff000

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.