reloc.h 1.4 KB
Newer Older
1 2
#include <endian.h>

R
Rich Felker 已提交
3 4
#if __BYTE_ORDER == __BIG_ENDIAN
#define ENDIAN_SUFFIX "eb"
B
Bobby Bingham 已提交
5 6 7 8
#else
#define ENDIAN_SUFFIX ""
#endif

R
Rich Felker 已提交
9 10 11 12 13 14
#if __SH_FPU_ANY__ || __SH4__
#define FP_SUFFIX ""
#else
#define FP_SUFFIX "-nofpu"
#endif

R
Rich Felker 已提交
15 16 17 18 19 20 21
#if __SH_FDPIC__
#define ABI_SUFFIX "-fdpic"
#else
#define ABI_SUFFIX ""
#endif

#define LDSO_ARCH "sh" ENDIAN_SUFFIX FP_SUFFIX ABI_SUFFIX
B
Bobby Bingham 已提交
22

23
#define TPOFF_K 8
B
Bobby Bingham 已提交
24

R
Rich Felker 已提交
25 26 27 28 29 30 31 32 33 34
#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

R
Rich Felker 已提交
35 36 37 38
#if __SH_FDPIC__
#define REL_FUNCDESC    R_SH_FUNCDESC
#define REL_FUNCDESC_VAL R_SH_FUNCDESC_VALUE
#undef  REL_RELATIVE
39
#define DL_FDPIC 1
40
#define FDPIC_CONSTDISP_FLAG 0x100
41 42 43 44 45 46 47 48
#define CRTJMP(pc,sp) do { \
	register size_t r8 __asm__("r8") = ((size_t *)(sp))[-2]; \
	__asm__ __volatile__( "jmp @%0 ; mov %1,r15" \
	: : "r"(pc), "r"(sp), "r"(r8) : "memory" ); } while(0)
#define GETFUNCSYM(fp, sym, got) __asm__ ( \
	"mov.l 1f,%0 ; add %1,%0 ; bra 2f ; nop ; .align 2 \n" \
	"1:	.long " #sym "@GOTOFFFUNCDESC \n2:" \
	: "=&r"(*fp) : "r"(got) : "memory" )
R
Rich Felker 已提交
49
#else
R
Rich Felker 已提交
50 51
#define CRTJMP(pc,sp) __asm__ __volatile__( \
	"jmp @%0 ; mov %1,r15" : : "r"(pc), "r"(sp) : "memory" )
R
Rich Felker 已提交
52
#endif