diff options
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0014-Added-relocations-for-MB-X.patch')
-rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils/0014-Added-relocations-for-MB-X.patch | 349 |
1 files changed, 349 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0014-Added-relocations-for-MB-X.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0014-Added-relocations-for-MB-X.patch new file mode 100644 index 00000000..404081e0 --- /dev/null +++ b/meta-microblaze/recipes-devtools/binutils/binutils/0014-Added-relocations-for-MB-X.patch | |||
@@ -0,0 +1,349 @@ | |||
1 | From 4e94c1683a806ac46f3a0d54bfe8f7247d5f0cbd Mon Sep 17 00:00:00 2001 | ||
2 | From: Nagaraju Mekala <nmekala@xilix.com> | ||
3 | Date: Tue, 11 Sep 2018 17:30:17 +0530 | ||
4 | Subject: [PATCH 14/34] Added relocations for MB-X | ||
5 | |||
6 | Conflicts: | ||
7 | bfd/bfd-in2.h | ||
8 | gas/config/tc-microblaze.c | ||
9 | |||
10 | Conflicts: | ||
11 | gas/config/tc-microblaze.c | ||
12 | --- | ||
13 | bfd/bfd-in2.h | 9 +++- | ||
14 | bfd/libbfd.h | 4 +- | ||
15 | bfd/reloc.c | 26 ++++++----- | ||
16 | gas/config/tc-microblaze.c | 90 ++++++++++++++++---------------------- | ||
17 | 4 files changed, 61 insertions(+), 68 deletions(-) | ||
18 | |||
19 | diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h | ||
20 | index 6cf701abf10..14e228c9c0e 100644 | ||
21 | --- a/bfd/bfd-in2.h | ||
22 | +++ b/bfd/bfd-in2.h | ||
23 | @@ -5387,13 +5387,18 @@ done here - only used for relaxing */ | ||
24 | /* This is a 64 bit reloc that stores the 32 bit pc relative | ||
25 | value in two words (with an imm instruction). No relocation is | ||
26 | done here - only used for relaxing */ | ||
27 | - BFD_RELOC_MICROBLAZE_64_NONE, | ||
28 | + BFD_RELOC_MICROBLAZE_64_PCREL, | ||
29 | |||
30 | -/* This is a 64 bit reloc that stores the 32 bit pc relative | ||
31 | +/* This is a 64 bit reloc that stores the 32 bit relative | ||
32 | * +value in two words (with an imml instruction). No relocation is | ||
33 | * +done here - only used for relaxing */ | ||
34 | BFD_RELOC_MICROBLAZE_64, | ||
35 | |||
36 | +/* This is a 64 bit reloc that stores the 32 bit pc relative | ||
37 | + * +value in two words (with an imm instruction). No relocation is | ||
38 | + * +done here - only used for relaxing */ | ||
39 | + BFD_RELOC_MICROBLAZE_64_NONE, | ||
40 | + | ||
41 | /* This is a 64 bit reloc that stores the 32 bit pc relative | ||
42 | value in two words (with an imm instruction). The relocation is | ||
43 | PC-relative GOT offset */ | ||
44 | diff --git a/bfd/libbfd.h b/bfd/libbfd.h | ||
45 | index e74c051e781..20086ba608b 100644 | ||
46 | --- a/bfd/libbfd.h | ||
47 | +++ b/bfd/libbfd.h | ||
48 | @@ -2991,14 +2991,14 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", | ||
49 | "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM", | ||
50 | "BFD_RELOC_MICROBLAZE_32_NONE", | ||
51 | "BFD_RELOC_MICROBLAZE_64_NONE", | ||
52 | - "BFD_RELOC_MICROBLAZE_64", | ||
53 | "BFD_RELOC_MICROBLAZE_64_GOTPC", | ||
54 | - "BFD_RELOC_MICROBLAZE_64_GPC", | ||
55 | "BFD_RELOC_MICROBLAZE_64_GOT", | ||
56 | "BFD_RELOC_MICROBLAZE_64_PLT", | ||
57 | "BFD_RELOC_MICROBLAZE_64_GOTOFF", | ||
58 | "BFD_RELOC_MICROBLAZE_32_GOTOFF", | ||
59 | "BFD_RELOC_MICROBLAZE_COPY", | ||
60 | + "BFD_RELOC_MICROBLAZE_64", | ||
61 | + "BFD_RELOC_MICROBLAZE_64_PCREL", | ||
62 | "BFD_RELOC_MICROBLAZE_64_TLS", | ||
63 | "BFD_RELOC_MICROBLAZE_64_TLSGD", | ||
64 | "BFD_RELOC_MICROBLAZE_64_TLSLD", | ||
65 | diff --git a/bfd/reloc.c b/bfd/reloc.c | ||
66 | index 0f99df91299..6165ff3adf1 100644 | ||
67 | --- a/bfd/reloc.c | ||
68 | +++ b/bfd/reloc.c | ||
69 | @@ -6875,24 +6875,12 @@ ENUMDOC | ||
70 | done here - only used for relaxing | ||
71 | ENUM | ||
72 | BFD_RELOC_MICROBLAZE_64_NONE | ||
73 | -ENUMDOC | ||
74 | - This is a 32 bit reloc that stores the 32 bit pc relative | ||
75 | - value in two words (with an imml instruction). No relocation is | ||
76 | - done here - only used for relaxing | ||
77 | -ENUM | ||
78 | - BFD_RELOC_MICROBLAZE_64 | ||
79 | ENUMDOC | ||
80 | This is a 64 bit reloc that stores the 32 bit pc relative | ||
81 | value in two words (with an imm instruction). No relocation is | ||
82 | done here - only used for relaxing | ||
83 | ENUM | ||
84 | BFD_RELOC_MICROBLAZE_64_GOTPC | ||
85 | -ENUMDOC | ||
86 | - This is a 64 bit reloc that stores the 32 bit pc relative | ||
87 | - value in two words (with an imml instruction). No relocation is | ||
88 | - done here - only used for relaxing | ||
89 | -ENUM | ||
90 | - BFD_RELOC_MICROBLAZE_64_GPC | ||
91 | ENUMDOC | ||
92 | This is a 64 bit reloc that stores the 32 bit pc relative | ||
93 | value in two words (with an imm instruction). The relocation is | ||
94 | @@ -6978,6 +6966,20 @@ ENUMDOC | ||
95 | value in two words (with an imm instruction). The relocation is | ||
96 | relative offset from start of TEXT. | ||
97 | |||
98 | + This is a 64 bit reloc that stores 64-bit thread pointer relative offset | ||
99 | + to two words (uses imml instruction). | ||
100 | +ENUM | ||
101 | +BFD_RELOC_MICROBLAZE_64, | ||
102 | +ENUMDOC | ||
103 | + This is a 64 bit reloc that stores the 64 bit pc relative | ||
104 | + value in two words (with an imml instruction). No relocation is | ||
105 | + done here - only used for relaxing | ||
106 | +ENUM | ||
107 | +BFD_RELOC_MICROBLAZE_64_PCREL, | ||
108 | +ENUMDOC | ||
109 | + This is a 32 bit reloc that stores the 32 bit pc relative | ||
110 | + value in two words (with an imml instruction). No relocation is | ||
111 | + done here - only used for relaxing | ||
112 | ENUM | ||
113 | BFD_RELOC_AARCH64_RELOC_START | ||
114 | ENUMDOC | ||
115 | diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c | ||
116 | index a6f12dda54a..9d4dbc12ab3 100644 | ||
117 | --- a/gas/config/tc-microblaze.c | ||
118 | +++ b/gas/config/tc-microblaze.c | ||
119 | @@ -95,6 +95,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP"; | ||
120 | #define TEXT_OFFSET 17 | ||
121 | #define TEXT_PC_OFFSET 18 | ||
122 | #define DEFINED_64_OFFSET 19 | ||
123 | +#define DEFINED_64_PC_OFFSET 20 | ||
124 | |||
125 | /* Initialize the relax table. */ | ||
126 | const relax_typeS md_relax_table[] = | ||
127 | @@ -119,7 +120,8 @@ const relax_typeS md_relax_table[] = | ||
128 | { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */ | ||
129 | { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 18: TEXT_PC_OFFSET. */ | ||
130 | // { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */ | ||
131 | - { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 17: DEFINED_64_OFFSET. */ | ||
132 | + { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 }, /* 19: DEFINED_64_OFFSET. */ | ||
133 | + { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE*2, 0 } /* 20: DEFINED_64_PC_OFFSET. */ | ||
134 | }; | ||
135 | |||
136 | static htab_t opcode_hash_control; /* Opcode mnemonics. */ | ||
137 | @@ -1184,33 +1186,6 @@ md_assemble (char * str) | ||
138 | inst |= (immed << IMM_LOW) & IMM_MASK; | ||
139 | } | ||
140 | } | ||
141 | -#if 0 //revisit | ||
142 | - else if (streq (name, "lli") || streq (name, "sli")) | ||
143 | - { | ||
144 | - temp = immed & 0xFFFFFFFFFFFF8000; | ||
145 | - if ((temp != 0) && (temp != 0xFFFFFFFFFFFF8000)) | ||
146 | - { | ||
147 | - /* Needs an immediate inst. */ | ||
148 | - opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imml"); | ||
149 | - if (opcode1 == NULL) | ||
150 | - { | ||
151 | - as_bad (_("unknown opcode \"%s\""), "imml"); | ||
152 | - return; | ||
153 | - } | ||
154 | - | ||
155 | - inst1 = opcode1->bit_sequence; | ||
156 | - inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK; | ||
157 | - output[0] = INST_BYTE0 (inst1); | ||
158 | - output[1] = INST_BYTE1 (inst1); | ||
159 | - output[2] = INST_BYTE2 (inst1); | ||
160 | - output[3] = INST_BYTE3 (inst1); | ||
161 | - output = frag_more (isize); | ||
162 | - } | ||
163 | - inst |= (reg1 << RD_LOW) & RD_MASK; | ||
164 | - inst |= (reg2 << RA_LOW) & RA_MASK; | ||
165 | - inst |= (immed << IMM_LOW) & IMM_MASK; | ||
166 | - } | ||
167 | -#endif | ||
168 | else | ||
169 | { | ||
170 | temp = immed & 0xFFFF8000; | ||
171 | @@ -1970,8 +1945,8 @@ md_assemble (char * str) | ||
172 | |||
173 | if (exp.X_op != O_constant) | ||
174 | { | ||
175 | - char *opc = NULL; | ||
176 | - //char *opc = str_microblaze_64; | ||
177 | + //char *opc = NULL; | ||
178 | + char *opc = str_microblaze_64; | ||
179 | relax_substateT subtype; | ||
180 | |||
181 | if (exp.X_md != 0) | ||
182 | @@ -2230,13 +2205,19 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, | ||
183 | fragP->fr_fix += INST_WORD_SIZE * 2; | ||
184 | fragP->fr_var = 0; | ||
185 | break; | ||
186 | + case DEFINED_64_PC_OFFSET: | ||
187 | + fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol, | ||
188 | + fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_PCREL); | ||
189 | + fragP->fr_fix += INST_WORD_SIZE * 2; | ||
190 | + fragP->fr_var = 0; | ||
191 | + break; | ||
192 | case DEFINED_64_OFFSET: | ||
193 | if (fragP->fr_symbol == GOT_symbol) | ||
194 | fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol, | ||
195 | - fragP->fr_offset, true, BFD_RELOC_MICROBLAZE_64_GPC); | ||
196 | + fragP->fr_offset, false, BFD_RELOC_MICROBLAZE_64_GPC); | ||
197 | else | ||
198 | fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol, | ||
199 | - fragP->fr_offset, true, BFD_RELOC_MICROBLAZE_64); | ||
200 | + fragP->fr_offset, false, BFD_RELOC_MICROBLAZE_64); | ||
201 | fragP->fr_fix += INST_WORD_SIZE * 2; | ||
202 | fragP->fr_var = 0; | ||
203 | break; | ||
204 | @@ -2246,7 +2227,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, | ||
205 | fragP->fr_offset, true, BFD_RELOC_MICROBLAZE_64_GOTPC); | ||
206 | else | ||
207 | fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol, | ||
208 | - fragP->fr_offset, true, BFD_RELOC_64); | ||
209 | + fragP->fr_offset, false, BFD_RELOC_64); | ||
210 | fragP->fr_fix += INST_WORD_SIZE * 2; | ||
211 | fragP->fr_var = 0; | ||
212 | break; | ||
213 | @@ -2464,14 +2445,17 @@ md_apply_fix (fixS * fixP, | ||
214 | } | ||
215 | } | ||
216 | break; | ||
217 | + | ||
218 | case BFD_RELOC_64_PCREL: | ||
219 | case BFD_RELOC_64: | ||
220 | case BFD_RELOC_MICROBLAZE_64_TEXTREL: | ||
221 | case BFD_RELOC_MICROBLAZE_64: | ||
222 | + case BFD_RELOC_MICROBLAZE_64_PCREL: | ||
223 | /* Add an imm instruction. First save the current instruction. */ | ||
224 | for (i = 0; i < INST_WORD_SIZE; i++) | ||
225 | buf[i + INST_WORD_SIZE] = buf[i]; | ||
226 | - if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64) | ||
227 | + if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64 | ||
228 | + || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL) | ||
229 | { | ||
230 | /* Generate the imm instruction. */ | ||
231 | opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imml"); | ||
232 | @@ -2484,6 +2468,10 @@ md_apply_fix (fixS * fixP, | ||
233 | inst1 = opcode1->bit_sequence; | ||
234 | if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy)) | ||
235 | inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK; | ||
236 | + if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64) | ||
237 | + fixP->fx_r_type = BFD_RELOC_64; | ||
238 | + if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL) | ||
239 | + fixP->fx_r_type = BFD_RELOC_64_PCREL; | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | @@ -2494,7 +2482,7 @@ md_apply_fix (fixS * fixP, | ||
244 | as_bad (_("unknown opcode \"%s\""), "imm"); | ||
245 | return; | ||
246 | } | ||
247 | - | ||
248 | + | ||
249 | inst1 = opcode1->bit_sequence; | ||
250 | if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy)) | ||
251 | inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK; | ||
252 | @@ -2542,7 +2530,7 @@ md_apply_fix (fixS * fixP, | ||
253 | opcode1 = (struct op_code_struct *) str_hash_find (opcode_hash_control, "imm"); | ||
254 | if (opcode1 == NULL) | ||
255 | { | ||
256 | - if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC) | ||
257 | + if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC) | ||
258 | as_bad (_("unknown opcode \"%s\""), "imml"); | ||
259 | else | ||
260 | as_bad (_("unknown opcode \"%s\""), "imm"); | ||
261 | @@ -2569,8 +2557,6 @@ md_apply_fix (fixS * fixP, | ||
262 | moves code around due to relaxing. */ | ||
263 | if (fixP->fx_r_type == BFD_RELOC_64_PCREL) | ||
264 | fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE; | ||
265 | - if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64) | ||
266 | - fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE; | ||
267 | else if (fixP->fx_r_type == BFD_RELOC_32) | ||
268 | fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE; | ||
269 | else | ||
270 | @@ -2621,33 +2607,24 @@ md_estimate_size_before_relax (fragS * fragP, | ||
271 | if(streq (fragP->fr_opcode, str_microblaze_64)) | ||
272 | { | ||
273 | /* Used as an absolute value. */ | ||
274 | - fragP->fr_subtype = DEFINED_64_OFFSET; | ||
275 | + fragP->fr_subtype = DEFINED_64_PC_OFFSET; | ||
276 | /* Variable part does not change. */ | ||
277 | - fragP->fr_var = INST_WORD_SIZE; | ||
278 | + fragP->fr_var = INST_WORD_SIZE*2; | ||
279 | } | ||
280 | else | ||
281 | { | ||
282 | fragP->fr_subtype = DEFINED_PC_OFFSET; | ||
283 | - /* Don't know now whether we need an imm instruction. */ | ||
284 | + /* Don't know now whether we need an imm instruction. */ | ||
285 | fragP->fr_var = INST_WORD_SIZE; | ||
286 | } | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | fragP->fr_subtype = DEFINED_PC_OFFSET; | ||
291 | - /* Don't know now whether we need an imm instruction. */ | ||
292 | + /* Don't know now whether we need an imm instruction. */ | ||
293 | fragP->fr_var = INST_WORD_SIZE; | ||
294 | } | ||
295 | } | ||
296 | - #if 0 | ||
297 | - else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type && | ||
298 | - !S_IS_WEAK (fragP->fr_symbol)) | ||
299 | - { | ||
300 | - fragP->fr_subtype = DEFINED_PC_OFFSET; | ||
301 | - /* Don't know now whether we need an imm instruction. */ | ||
302 | - fragP->fr_var = INST_WORD_SIZE; | ||
303 | - } | ||
304 | -#endif | ||
305 | else if (S_IS_DEFINED (fragP->fr_symbol) | ||
306 | && (((S_GET_SEGMENT (fragP->fr_symbol))->flags & SEC_CODE) == 0)) | ||
307 | { | ||
308 | @@ -2677,6 +2654,13 @@ md_estimate_size_before_relax (fragS * fragP, | ||
309 | /* Variable part does not change. */ | ||
310 | fragP->fr_var = INST_WORD_SIZE*2; | ||
311 | } | ||
312 | + else if (streq (fragP->fr_opcode, str_microblaze_64)) | ||
313 | + { | ||
314 | + /* Used as an absolute value. */ | ||
315 | + fragP->fr_subtype = DEFINED_64_OFFSET; | ||
316 | + /* Variable part does not change. */ | ||
317 | + fragP->fr_var = INST_WORD_SIZE; | ||
318 | + } | ||
319 | else if (streq (fragP->fr_opcode, str_microblaze_ro_anchor)) | ||
320 | { | ||
321 | /* It is accessed using the small data read only anchor. */ | ||
322 | @@ -2751,6 +2735,7 @@ md_estimate_size_before_relax (fragS * fragP, | ||
323 | case TLSTPREL_OFFSET: | ||
324 | case TLSDTPREL_OFFSET: | ||
325 | case DEFINED_64_OFFSET: | ||
326 | + case DEFINED_64_PC_OFFSET: | ||
327 | fragP->fr_var = INST_WORD_SIZE*2; | ||
328 | break; | ||
329 | case DEFINED_RO_SEGMENT: | ||
330 | @@ -2804,7 +2789,7 @@ md_pcrel_from_section (fixS * fixp, segT sec ATTRIBUTE_UNUSED) | ||
331 | else | ||
332 | { | ||
333 | /* The case where we are going to resolve things... */ | ||
334 | - if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64) | ||
335 | + if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL) | ||
336 | return fixp->fx_where + fixp->fx_frag->fr_address + INST_WORD_SIZE; | ||
337 | else | ||
338 | return fixp->fx_where + fixp->fx_frag->fr_address; | ||
339 | @@ -2839,6 +2824,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp) | ||
340 | case BFD_RELOC_MICROBLAZE_64_GOTPC: | ||
341 | case BFD_RELOC_MICROBLAZE_64_GPC: | ||
342 | case BFD_RELOC_MICROBLAZE_64: | ||
343 | + case BFD_RELOC_MICROBLAZE_64_PCREL: | ||
344 | case BFD_RELOC_MICROBLAZE_64_GOT: | ||
345 | case BFD_RELOC_MICROBLAZE_64_PLT: | ||
346 | case BFD_RELOC_MICROBLAZE_64_GOTOFF: | ||
347 | -- | ||
348 | 2.37.1 (Apple Git-137.1) | ||
349 | |||