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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * Various assmbly language/system dependent  hacks that are required
3
 * so that we can minimize the amount of platform specific code.
4
 */
5
 
6
/*
7
 * Define this if the system uses RELOCA.
8
 */
9
#define ELF_USES_RELOCA
10
 
11
/*
12
 * Get a pointer to the argv array.  On many platforms this can be just
13
 * the address if the first argument, on other platforms we need to
14
 * do something a little more subtle here.
15
 */
16
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*)   ARGS)
17
 
18
/*
19
 * Initialization sequence for a GOT.
20
 */
21
#define INIT_GOT(GOT_BASE,MODULE) \
22
{                               \
23
  GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
24
  GOT_BASE[1] = (unsigned long) (MODULE); \
25
}
26
 
27
/*
28
 * Here is a macro to perform a relocation.  This is only used when
29
 * bootstrapping the dynamic loader.  RELP is the relocation that we
30
 * are performing, REL is the pointer to the address we are relocating.
31
 * SYMBOL is the symbol involved in the relocation, and LOAD is the
32
 * load address.
33
 */
34
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)    \
35
        switch(ELF32_R_TYPE((RELP)->r_info)){                   \
36
        case R_SH_REL32:                                        \
37
                *(REL)  = (SYMBOL) + (RELP)->r_addend           \
38
                            - (unsigned long)(REL);             \
39
                break;                                          \
40
        case R_SH_DIR32:                                        \
41
        case R_SH_GLOB_DAT:                                     \
42
        case R_SH_JMP_SLOT:                                     \
43
                *(REL)  = (SYMBOL) + (RELP)->r_addend;          \
44
                break;                                          \
45
        case R_SH_RELATIVE:                                     \
46
                *(REL)  = (LOAD) + (RELP)->r_addend;            \
47
                break;                                          \
48
        case R_SH_NONE:                                         \
49
                break;                                          \
50
        default:                                                \
51
                SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc type "); \
52
                SEND_NUMBER_STDERR(ELF32_R_TYPE((RELP)->r_info), 1); \
53
                SEND_STDERR("REL, SYMBOL, LOAD: ");             \
54
                SEND_ADDRESS_STDERR(REL, 0);                     \
55
                SEND_STDERR(", ");                              \
56
                SEND_ADDRESS_STDERR(SYMBOL, 0);                  \
57
                SEND_STDERR(", ");                              \
58
                SEND_ADDRESS_STDERR(LOAD, 1);                   \
59
                _dl_exit(1);                                    \
60
        }
61
 
62
 
63
/*
64
 * Transfer control to the user's application, once the dynamic loader
65
 * is done.  This routine has to exit the current function, then
66
 * call the _dl_elf_main function.
67
 */
68
 
69
#define START()   return _dl_elf_main;
70
 
71
 
72
 
73
/* Here we define the magic numbers that this dynamic loader should accept */
74
 
75
#define MAGIC1 EM_SH
76
#undef  MAGIC2
77
/* Used for error messages */
78
#define ELF_TARGET "sh"
79
 
80
struct elf_resolve;
81
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
82
 
83
static __inline__ unsigned int
84
_dl_urem(unsigned int n, unsigned int base)
85
{
86
  int res;
87
 
88
        __asm__ (""\
89
                "mov    #0, r0\n\t" \
90
                "div0u\n\t" \
91
                "" \
92
                "! get one bit from the msb of the numerator into the T\n\t" \
93
                "! bit and divide it by whats in %2.  Put the answer bit\n\t" \
94
                "! into the T bit so it can come out again at the bottom\n\t" \
95
                ""                              \
96
                "rotcl  %1 ; div1 %2, r0\n\t"   \
97
                "rotcl  %1 ; div1 %2, r0\n\t"   \
98
                "rotcl  %1 ; div1 %2, r0\n\t"   \
99
                "rotcl  %1 ; div1 %2, r0\n\t"   \
100
                "rotcl  %1 ; div1 %2, r0\n\t"   \
101
                "rotcl  %1 ; div1 %2, r0\n\t"   \
102
                "rotcl  %1 ; div1 %2, r0\n\t"   \
103
                "rotcl  %1 ; div1 %2, r0\n\t"   \
104
                ""                              \
105
                "rotcl  %1 ; div1 %2, r0\n\t"   \
106
                "rotcl  %1 ; div1 %2, r0\n\t"   \
107
                "rotcl  %1 ; div1 %2, r0\n\t"   \
108
                "rotcl  %1 ; div1 %2, r0\n\t"   \
109
                "rotcl  %1 ; div1 %2, r0\n\t"   \
110
                "rotcl  %1 ; div1 %2, r0\n\t"   \
111
                "rotcl  %1 ; div1 %2, r0\n\t"   \
112
                "rotcl  %1 ; div1 %2, r0\n\t"   \
113
                ""                              \
114
                "rotcl  %1 ; div1 %2, r0\n\t"   \
115
                "rotcl  %1 ; div1 %2, r0\n\t"   \
116
                "rotcl  %1 ; div1 %2, r0\n\t"   \
117
                "rotcl  %1 ; div1 %2, r0\n\t"   \
118
                "rotcl  %1 ; div1 %2, r0\n\t"   \
119
                "rotcl  %1 ; div1 %2, r0\n\t"   \
120
                "rotcl  %1 ; div1 %2, r0\n\t"   \
121
                "rotcl  %1 ; div1 %2, r0\n\t"   \
122
                ""                              \
123
                "rotcl  %1 ; div1 %2, r0\n\t"   \
124
                "rotcl  %1 ; div1 %2, r0\n\t"   \
125
                "rotcl  %1 ; div1 %2, r0\n\t"   \
126
                "rotcl  %1 ; div1 %2, r0\n\t"   \
127
                "rotcl  %1 ; div1 %2, r0\n\t"   \
128
                "rotcl  %1 ; div1 %2, r0\n\t"   \
129
                "rotcl  %1 ; div1 %2, r0\n\t"   \
130
                "rotcl  %1 ; div1 %2, r0\n\t"   \
131
                "rotcl  %1\n\t"
132
                : "=r" (res)
133
                : "0" (n), "r" (base)
134
                : "r0","cc");
135
 
136
        return n - (base * res);
137
}
138
 
139
#define do_rem(result, n, base)     ((result) = _dl_urem((n), (base)))
140
 
141
/* 4096 bytes alignment */
142
#define PAGE_ALIGN 0xfffff000
143
#define ADDR_ALIGN 0xfff
144
#define OFFS_ALIGN 0x7ffff000

powered by: WebSVN 2.1.0

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