musl/arch/sh/reloc.h
Rich Felker d4c82d05b8 add sh fdpic subarch variants
with this commit it should be possible to produce a working
static-linked fdpic libc and application binaries for sh.

the changes in reloc.h are largely unused at this point since dynamic
linking is not supported, but the CRTJMP macro is used one place
outside of dynamic linking, in __unmapself.
2015-09-12 03:23:49 +00:00

46 lines
1.1 KiB
C

#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#define ENDIAN_SUFFIX "eb"
#else
#define ENDIAN_SUFFIX ""
#endif
#if __SH_FPU_ANY__ || __SH4__
#define FP_SUFFIX ""
#else
#define FP_SUFFIX "-nofpu"
#endif
#if __SH_FDPIC__
#define ABI_SUFFIX "-fdpic"
#else
#define ABI_SUFFIX ""
#endif
#define LDSO_ARCH "sh" ENDIAN_SUFFIX FP_SUFFIX ABI_SUFFIX
#define TPOFF_K 8
#define REL_SYMBOLIC R_SH_DIR32
#define REL_OFFSET R_SH_REL32
#define REL_GOT R_SH_GLOB_DAT
#define REL_PLT R_SH_JMP_SLOT
#define REL_RELATIVE R_SH_RELATIVE
#define REL_COPY R_SH_COPY
#define REL_DTPMOD R_SH_TLS_DTPMOD32
#define REL_DTPOFF R_SH_TLS_DTPOFF32
#define REL_TPOFF R_SH_TLS_TPOFF32
#if __SH_FDPIC__
#define REL_FUNCDESC R_SH_FUNCDESC
#define REL_FUNCDESC_VAL R_SH_FUNCDESC_VALUE
#undef REL_RELATIVE
#define CRTJMP(pc,sp) __asm__ __volatile__( \
"mov.l @%0+,r0 ; mov.l @%0,r12 ; jmp @r0 ; mov %1,r15" \
: : "r"(pc), "r"(sp) : "r0", "memory" )
#else
#define CRTJMP(pc,sp) __asm__ __volatile__( \
"jmp @%0 ; mov %1,r15" : : "r"(pc), "r"(sp) : "memory" )
#endif