X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=arch%2Fmips%2Freloc.h;h=4b81d328612f059f9dc9561c09d6dbadb4ff5142;hb=c0ed5a201b2bdb6d1896064bec0020c9973db0a1;hp=853c8b85f4aa16ec003642afb18e1f734f13916c;hpb=babf820180368f00742ec65b2050a82380d7c542;p=musl diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h index 853c8b85..4b81d328 100644 --- a/arch/mips/reloc.h +++ b/arch/mips/reloc.h @@ -1,25 +1,40 @@ #include #include +#include -#define ETC_LDSO_PATH "/etc/ld-musl-mips.path" +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define ENDIAN_SUFFIX "el" +#else +#define ENDIAN_SUFFIX "" +#endif -#define IS_COPY(x) ((x)==R_MIPS_COPY) -#define IS_PLT(x) 1 +#ifdef __mips_soft_float +#define FP_SUFFIX "-sf" +#else +#define FP_SUFFIX "" +#endif -static inline void do_single_reloc(size_t *reloc_addr, int type, size_t sym_val, size_t sym_size, unsigned char *base_addr, size_t addend) +#define LDSO_ARCH "mips" ENDIAN_SUFFIX FP_SUFFIX + +#define TPOFF_K (-0x7000) + +static int remap_rel(int type) { switch(type) { - case R_MIPS_JUMP_SLOT: - *reloc_addr = sym_val; - break; case R_MIPS_REL32: - if (sym_val) *reloc_addr += sym_val; - else *reloc_addr += (size_t)base_addr; - break; + return REL_SYM_OR_REL; + case R_MIPS_JUMP_SLOT: + return REL_PLT; case R_MIPS_COPY: - memcpy(reloc_addr, (void *)sym_val, sym_size); - break; + return REL_COPY; + case R_MIPS_TLS_DTPMOD32: + return REL_DTPMOD; + case R_MIPS_TLS_DTPREL32: + return REL_DTPOFF; + case R_MIPS_TLS_TPREL32: + return REL_TPOFF; } + return 0; } void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got) @@ -29,13 +44,13 @@ void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got) for (a+=c+1; *a; a++); for (a++; *a; a+=2) if (*a<20) t[*a] = a[1]; base = (char *)t[AT_BASE]; - if (!base) base = (char *)(t[AT_PHDR] & -4096); + if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]); for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1]; n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000]; for (a=got; n; a++, n--) *a += (size_t)base; } -static void do_relocs(unsigned char *base, size_t *rel, size_t rel_size, size_t stride, Sym *syms, char *strings, struct dso *dso); +static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride); static void do_arch_relocs(struct dso *this, struct dso *head) { @@ -65,9 +80,10 @@ static void do_arch_relocs(struct dso *this, struct dso *head) rel[0] = got; rel[1] = sym-this->syms << 8 | R_MIPS_JUMP_SLOT; *(size_t *)(base+got) = 0; - do_relocs(base, rel, sizeof rel, 2, this->syms, this->strings, head); + do_relocs(this, rel, sizeof rel, 2); } } #define NEED_ARCH_RELOCS 1 #define DYNAMIC_IS_RO 1 +#define ARCH_SYM_REJECT_UND(s) (!((s)->st_other & STO_MIPS_PLT))