1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* CRIS can never use Elf32_Rel relocations. */
#define ELF_USES_RELOCA
/*
* Get a pointer to the argv array. On many platforms this can be just
* the address if the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
/*
* Initialization sequence for a GOT.
*/
#define INIT_GOT(GOT_BASE,MODULE) \
{ \
GOT_BASE[1] = (unsigned long) MODULE; \
GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
}
/*
* Here is a macro to perform a relocation. This is only used when
* bootstrapping the dynamic loader. RELP is the relocation that we
* are performing, REL is the pointer to the address we are relocating.
* SYMBOL is the symbol involved in the relocation, and LOAD is the
* load address.
*/
#define PERFORM_BOOTSTRAP_RELOC(RELP, REL, SYMBOL, LOAD) \
switch (ELF32_R_TYPE((RELP)->r_info)) { \
case R_CRIS_GLOB_DAT: \
case R_CRIS_JUMP_SLOT: \
case R_CRIS_32: \
*REL = SYMBOL; \
break; \
case R_CRIS_16_PCREL: \
*(short *) *REL = SYMBOL + (RELP)->r_addend - *REL - 2; \
break; \
case R_CRIS_32_PCREL: \
*REL = SYMBOL + (RELP)->r_addend - *REL - 4; \
break; \
case R_CRIS_NONE: \
break; \
case R_CRIS_RELATIVE: \
*REL = (unsigned long) LOAD + (RELP)->r_addend; \
break; \
default: \
_dl_exit(1); \
break; \
}
/*
* Transfer control to the user's application once the dynamic loader
* is done. This routine has to exit the current function, then call
* _dl_elf_main.
*/
#define START() __asm__ volatile ("moveq 0,$r8\n\t" \
"move $r8,$srp\n\t" \
"move.d %1,$sp\n\t" \
"jump %0\n\t" \
: : "r" (_dl_elf_main), "r" (args))
/* Defined some magic numbers that this ld.so should accept. */
#define MAGIC1 EM_CRIS
#undef MAGIC2
#define ELF_TARGET "CRIS"
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
/* Cheap modulo implementation, taken from arm/ld_sysdep.h. */
static inline unsigned long
cris_mod(unsigned long m, unsigned long p)
{
unsigned long i, t, inc;
i = p;
t = 0;
while (!(i & (1 << 31))) {
i <<= 1;
t++;
}
t--;
for (inc = t; inc > 2; inc--) {
i = p << inc;
if (i & (1 << 31))
break;
while (m >= i) {
m -= i;
i <<= 1;
if (i & (1 << 31))
break;
if (i < p)
break;
}
}
while (m >= p)
m -= p;
return m;
}
#define do_rem(result, n, base) result = cris_mod(n, base);
/* 8192 bytes alignment */
#define PAGE_ALIGN 0xffffe000
#define ADDR_ALIGN 0x1fff
#define OFFS_ALIGN 0xffffe000
|