5 #if __BYTE_ORDER == __LITTLE_ENDIAN
6 #define ENDIAN_SUFFIX "el"
8 #define ENDIAN_SUFFIX ""
11 #ifdef __mips_soft_float
12 #define FP_SUFFIX "-sf"
17 #define LDSO_ARCH "mips" ENDIAN_SUFFIX FP_SUFFIX
19 #define IS_COPY(x) ((x)==R_MIPS_COPY)
22 static inline int do_single_reloc(
23 struct dso *self, unsigned char *base_addr,
24 size_t *reloc_addr, int type, size_t addend,
25 Sym *sym, size_t sym_size,
26 struct symdef def, size_t sym_val)
29 case R_MIPS_JUMP_SLOT:
30 *reloc_addr = sym_val;
33 if (sym_val) *reloc_addr += sym_val;
34 else *reloc_addr += (size_t)base_addr;
37 memcpy(reloc_addr, (void *)sym_val, sym_size);
39 case R_MIPS_TLS_DTPMOD32:
40 *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
42 case R_MIPS_TLS_DTPREL32:
43 *reloc_addr += def.sym->st_value;
45 case R_MIPS_TLS_TPREL32:
46 *reloc_addr += def.sym
47 ? def.sym->st_value + def.dso->tls_offset - 0x7000
48 : self->tls_offset - 0x7000;
54 void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got)
58 for (a+=c+1; *a; a++);
59 for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
60 base = (char *)t[AT_BASE];
61 if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
62 for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1];
63 n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000];
64 for (a=got; n; a++, n--) *a += (size_t)base;
67 static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride);
69 static void do_arch_relocs(struct dso *this, struct dso *head)
71 unsigned char *base = this->base;
72 size_t *dynv = this->dynv;
78 for (i=0; dynv[i]; i+=2) {
79 if (dynv[i]-0x70000000UL<20)
80 dyn[dynv[i]&31] = dynv[i+1];
81 else if (dynv[i] == DT_PLTGOT)
84 i = dyn[DT_MIPS_LOCAL_GOTNO-0x70000000];
85 if (this->shortname && !strcmp(this->shortname, "libc.so")) {
86 got += sizeof(size_t) * i;
88 for (; i; i--, got+=sizeof(size_t))
89 *(size_t *)(base+got) += (size_t)base;
91 sym = this->syms + dyn[DT_MIPS_GOTSYM-0x70000000];
92 i = dyn[DT_MIPS_SYMTABNO-0x70000000] - dyn[DT_MIPS_GOTSYM-0x70000000];
93 for (; i; i--, got+=sizeof(size_t), sym++) {
95 rel[1] = sym-this->syms << 8 | R_MIPS_JUMP_SLOT;
96 *(size_t *)(base+got) = 0;
97 do_relocs(this, rel, sizeof rel, 2);
101 #define NEED_ARCH_RELOCS 1
102 #define DYNAMIC_IS_RO 1