X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=arch%2Fpowerpc%2Freloc.h;h=73c583b7be6bf561ddfcd8e250492e25eb40172e;hb=7424ac58b1f47adb03de55de5998c530aee91551;hp=58e482d6b819886f2bd673e958b56c0ca9b04407;hpb=8bb181622222f2ee3462c8b021bcae4fcdbbd37a;p=musl diff --git a/arch/powerpc/reloc.h b/arch/powerpc/reloc.h index 58e482d6..73c583b7 100644 --- a/arch/powerpc/reloc.h +++ b/arch/powerpc/reloc.h @@ -1,36 +1,44 @@ #include #include -#define ETC_LDSO_PATH "/etc/ld-musl-powerpc.path" +#define LDSO_ARCH "powerpc" -#define IS_COPY(x) ((x)==R_PPC_COPY) -#define IS_PLT(x) ((x)==R_PPC_JMP_SLOT) +#define TPOFF_K (-0x7000) -// see linux' arch/powerpc/include/asm/elf.h -static inline void do_single_reloc( - struct dso *self, unsigned char *base_addr, - size_t *reloc_addr, int type, size_t addend, - Sym *sym, size_t sym_size, - struct symdef def, size_t sym_val) +static int remap_rel(int type) { switch(type) { + case R_PPC_ADDR32: + return REL_SYMBOLIC; case R_PPC_GLOB_DAT: + return REL_GOT; case R_PPC_JMP_SLOT: - *reloc_addr = sym_val; - break; - case R_PPC_REL32: - if (sym_val) *reloc_addr += sym_val; - else *reloc_addr += (size_t)base_addr; - break; - case R_PPC_COPY: - memcpy(reloc_addr, (void *)sym_val, sym_size); - break; + return REL_PLT; case R_PPC_RELATIVE: - *reloc_addr += (size_t)base_addr; - break; - //case R_PPC64_DTPMOD64: //R_X86_64_DTPMOD64: - case R_PPC_DTPMOD32: //R_386_TLS_DTPMOD32: - *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id; - break; + return REL_RELATIVE; + case R_PPC_COPY: + return REL_COPY; + case R_PPC_DTPMOD32: + return REL_DTPMOD; + case R_PPC_DTPREL32: + return REL_DTPOFF; + case R_PPC_TPREL32: + return REL_TPOFF; } + return 0; +} + +void __reloc_self(int c, size_t *a, size_t *dynv) +{ + char *base; + size_t t[20], n; + 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] & -t[AT_PAGESZ]); + for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1]; + n = t[DT_RELASZ]; + for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12) + if (a[1]%256 == R_PPC_RELATIVE) + *(size_t *)(base+a[0]) = (size_t)base + a[2]; }