4 #define ETC_LDSO_PATH "/etc/ld-musl-mips.path"
6 #define IS_COPY(x) ((x)==R_MIPS_COPY)
9 static inline void do_single_reloc(
10 struct dso *self, unsigned char *base_addr,
11 size_t *reloc_addr, int type, size_t addend,
12 Sym *sym, size_t sym_size,
13 struct symdef def, size_t sym_val)
16 case R_MIPS_JUMP_SLOT:
17 *reloc_addr = sym_val;
20 if (sym_val) *reloc_addr += sym_val;
21 else *reloc_addr += (size_t)base_addr;
24 memcpy(reloc_addr, (void *)sym_val, sym_size);
26 case R_MIPS_TLS_DTPMOD32:
27 *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
29 case R_MIPS_TLS_DTPREL32:
30 *reloc_addr += def.sym->st_value;
32 case R_MIPS_TLS_TPREL32:
33 *reloc_addr += def.sym
34 ? def.sym->st_value + def.dso->tls_offset - 0x7000
35 : self->tls_offset - 0x7000;
40 void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got)
44 for (a+=c+1; *a; a++);
45 for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
46 base = (char *)t[AT_BASE];
47 if (!base) base = (char *)(t[AT_PHDR] & -4096);
48 for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1];
49 n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000];
50 for (a=got; n; a++, n--) *a += (size_t)base;
53 static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride);
55 static void do_arch_relocs(struct dso *this, struct dso *head)
57 unsigned char *base = this->base;
58 size_t *dynv = this->dynv;
64 for (i=0; dynv[i]; i+=2) {
65 if (dynv[i]-0x70000000UL<20)
66 dyn[dynv[i]&31] = dynv[i+1];
67 else if (dynv[i] == DT_PLTGOT)
70 i = dyn[DT_MIPS_LOCAL_GOTNO-0x70000000];
71 if (this->shortname && !strcmp(this->shortname, "libc.so")) {
72 got += sizeof(size_t) * i;
74 for (; i; i--, got+=sizeof(size_t))
75 *(size_t *)(base+got) += (size_t)base;
77 sym = this->syms + dyn[DT_MIPS_GOTSYM-0x70000000];
78 i = dyn[DT_MIPS_SYMTABNO-0x70000000] - dyn[DT_MIPS_GOTSYM-0x70000000];
79 for (; i; i--, got+=sizeof(size_t), sym++) {
81 rel[1] = sym-this->syms << 8 | R_MIPS_JUMP_SLOT;
82 *(size_t *)(base+got) = 0;
83 do_relocs(this, rel, sizeof rel, 2);
87 #define NEED_ARCH_RELOCS 1
88 #define DYNAMIC_IS_RO 1