source: EcnlProtoTool/trunk/tcc-0.9.27/c67-link.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 3.3 KB
Line 
1#ifdef TARGET_DEFS_ONLY
2
3#define EM_TCC_TARGET EM_C60
4
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
12
13#define R_NUM R_C60_NUM
14
15#define ELF_START_ADDR 0x00000400
16#define ELF_PAGE_SIZE 0x1000
17
18#define PCRELATIVE_DLLPLT 0
19#define RELOCATE_DLLPLT 0
20
21#else /* !TARGET_DEFS_ONLY */
22
23#include "tcc.h"
24
25/* Returns 1 for a code relocation, 0 for a data relocation. For unknown
26 relocations, returns -1. */
27int code_reloc (int reloc_type)
28{
29 switch (reloc_type) {
30 case R_C60_32:
31 case R_C60LO16:
32 case R_C60HI16:
33 case R_C60_GOT32:
34 case R_C60_GOTOFF:
35 case R_C60_GOTPC:
36 case R_C60_COPY:
37 return 0;
38
39 case R_C60_PLT32:
40 return 1;
41 }
42
43 tcc_error ("Unknown relocation type: %d", reloc_type);
44 return -1;
45}
46
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
49 different values. */
50int gotplt_entry_type (int reloc_type)
51{
52 switch (reloc_type) {
53 case R_C60_32:
54 case R_C60LO16:
55 case R_C60HI16:
56 case R_C60_COPY:
57 return NO_GOTPLT_ENTRY;
58
59 case R_C60_GOTOFF:
60 case R_C60_GOTPC:
61 return BUILD_GOT_ONLY;
62
63 case R_C60_PLT32:
64 case R_C60_GOT32:
65 return ALWAYS_GOTPLT_ENTRY;
66 }
67
68 tcc_error ("Unknown relocation type: %d", reloc_type);
69 return -1;
70}
71
72ST_FUNC unsigned create_plt_entry(TCCState *s1, unsigned got_offset, struct sym_attr *attr)
73{
74 tcc_error("C67 got not implemented");
75 return 0;
76}
77
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) */
80ST_FUNC void relocate_plt(TCCState *s1)
81{
82 uint8_t *p, *p_end;
83
84 if (!s1->plt)
85 return;
86
87 p = s1->plt->data;
88 p_end = p + s1->plt->data_offset;
89
90 if (p < p_end) {
91 /* XXX: TODO */
92 while (p < p_end) {
93 /* XXX: TODO */
94 }
95 }
96}
97
98void relocate_init(Section *sr) {}
99
100void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t addr, addr_t val)
101{
102 switch(type) {
103 case R_C60_32:
104 *(int *)ptr += val;
105 break;
106 case R_C60LO16:
107 {
108 uint32_t orig;
109
110 /* put the low 16 bits of the absolute address add to what is
111 already there */
112 orig = ((*(int *)(ptr )) >> 7) & 0xffff;
113 orig |= (((*(int *)(ptr+4)) >> 7) & 0xffff) << 16;
114
115 /* patch both at once - assumes always in pairs Low - High */
116 *(int *) ptr = (*(int *) ptr & (~(0xffff << 7)) ) |
117 (((val+orig) & 0xffff) << 7);
118 *(int *)(ptr+4) = (*(int *)(ptr+4) & (~(0xffff << 7)) ) |
119 ((((val+orig)>>16) & 0xffff) << 7);
120 }
121 break;
122 case R_C60HI16:
123 break;
124 default:
125 fprintf(stderr,"FIXME: handle reloc type %x at %x [%p] to %x\n",
126 type, (unsigned) addr, ptr, (unsigned) val);
127 break;
128 }
129}
130
131#endif /* !TARGET_DEFS_ONLY */
Note: See TracBrowser for help on using the repository browser.