1 #ifdef TARGET_DEFS_ONLY
3 #define EM_TCC_TARGET EM_C60
5 /* relocation type for 32 bit data relocation */
6 #define R_DATA_32 R_C60_32
7 #define R_DATA_PTR R_C60_32
8 #define R_JMP_SLOT R_C60_JMP_SLOT
9 #define R_GLOB_DAT R_C60_GLOB_DAT
10 #define R_COPY R_C60_COPY
11 #define R_RELATIVE R_C60_RELATIVE
13 #define R_NUM R_C60_NUM
15 #define ELF_START_ADDR 0x00000400
16 #define ELF_PAGE_SIZE 0x1000
18 #define PCRELATIVE_DLLPLT 0
19 #define RELOCATE_DLLPLT 0
21 #else /* !TARGET_DEFS_ONLY */
25 /* Returns 1 for a code relocation, 0 for a data relocation. For unknown
26 relocations, returns -1. */
27 int code_reloc (int reloc_type
)
43 tcc_error ("Unknown relocation type: %d", reloc_type
);
47 /* Returns an enumerator to describe whether and when the relocation needs a
48 GOT and/or PLT entry to be created. See tcc.h for a description of the
50 int gotplt_entry_type (int reloc_type
)
57 return NO_GOTPLT_ENTRY
;
61 return BUILD_GOT_ONLY
;
65 return ALWAYS_GOTPLT_ENTRY
;
68 tcc_error ("Unknown relocation type: %d", reloc_type
);
72 ST_FUNC
unsigned create_plt_entry(TCCState
*s1
, unsigned got_offset
, struct sym_attr
*attr
)
74 tcc_error("C67 got not implemented");
78 /* relocate the PLT: compute addresses and offsets in the PLT now that final
79 address for PLT and GOT are known (see fill_program_header) */
80 ST_FUNC
void relocate_plt(TCCState
*s1
)
88 p_end
= p
+ s1
->plt
->data_offset
;
98 void relocate_init(Section
*sr
) {}
99 void relocate_fini(Section
*sr
) {}
101 void relocate(TCCState
*s1
, ElfW_Rel
*rel
, int type
, unsigned char *ptr
, addr_t addr
, addr_t val
)
111 /* put the low 16 bits of the absolute address add to what is
113 orig
= ((*(int *)(ptr
)) >> 7) & 0xffff;
114 orig
|= (((*(int *)(ptr
+4)) >> 7) & 0xffff) << 16;
116 /* patch both at once - assumes always in pairs Low - High */
117 *(int *) ptr
= (*(int *) ptr
& (~(0xffff << 7)) ) |
118 (((val
+orig
) & 0xffff) << 7);
119 *(int *)(ptr
+4) = (*(int *)(ptr
+4) & (~(0xffff << 7)) ) |
120 ((((val
+orig
)>>16) & 0xffff) << 7);
126 fprintf(stderr
,"FIXME: handle reloc type %x at %x [%p] to %x\n",
127 type
, (unsigned) addr
, ptr
, (unsigned) val
);
132 #endif /* !TARGET_DEFS_ONLY */