Commit | Line | Data |
---|---|---|
40b36596 | 1 | /* 32-bit ELF support for TI C6X |
219d1afa | 2 | Copyright (C) 2010-2018 Free Software Foundation, Inc. |
c0621d88 | 3 | Contributed by Joseph Myers <joseph@codesourcery.com> |
07d6d2b8 | 4 | Bernd Schmidt <bernds@codesourcery.com> |
40b36596 JM |
5 | |
6 | This file is part of BFD, the Binary File Descriptor library. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
21 | MA 02110-1301, USA. */ | |
22 | ||
23 | #include "sysdep.h" | |
fbd9ad90 | 24 | #include <limits.h> |
40b36596 JM |
25 | #include "bfd.h" |
26 | #include "libbfd.h" | |
27 | #include "libiberty.h" | |
28 | #include "elf-bfd.h" | |
29 | #include "elf/tic6x.h" | |
41820509 JM |
30 | #include "elf32-tic6x.h" |
31 | ||
ac145307 BS |
32 | #define ELF_DYNAMIC_INTERPRETER "/lib/ld-uClibc.so.0" |
33 | ||
34 | /* DSBT binaries have a default 128K stack. */ | |
35 | #define DEFAULT_STACK_SIZE 0x20000 | |
36 | ||
37 | /* The size in bytes of an entry in the procedure linkage table. */ | |
38 | #define PLT_ENTRY_SIZE 24 | |
39 | ||
40 | /* TI C6X ELF linker hash table. */ | |
41 | ||
42 | struct elf32_tic6x_link_hash_table | |
43 | { | |
44 | struct elf_link_hash_table elf; | |
45 | ||
ac145307 BS |
46 | /* C6X specific command line arguments. */ |
47 | struct elf32_tic6x_params params; | |
48 | ||
49 | /* Small local sym cache. */ | |
50 | struct sym_cache sym_cache; | |
51 | ||
52 | /* The output BFD, for convenience. */ | |
53 | bfd *obfd; | |
54 | ||
55 | /* The .dsbt section. */ | |
56 | asection *dsbt; | |
57 | }; | |
58 | ||
59 | /* Get the TI C6X ELF linker hash table from a link_info structure. */ | |
60 | ||
61 | #define elf32_tic6x_hash_table(p) \ | |
62 | ((struct elf32_tic6x_link_hash_table *) ((p)->hash)) | |
63 | ||
64 | /* TI C6X ELF linker hash entry. */ | |
65 | ||
66 | struct elf32_tic6x_link_hash_entry | |
67 | { | |
68 | struct elf_link_hash_entry elf; | |
69 | ||
70 | /* Track dynamic relocs copied for this symbol. */ | |
71 | struct elf_dyn_relocs *dyn_relocs; | |
72 | }; | |
73 | ||
fbd9ad90 PB |
74 | typedef enum |
75 | { | |
76 | DELETE_EXIDX_ENTRY, | |
77 | INSERT_EXIDX_CANTUNWIND_AT_END | |
78 | } | |
79 | tic6x_unwind_edit_type; | |
80 | ||
81 | /* A (sorted) list of edits to apply to an unwind table. */ | |
82 | typedef struct tic6x_unwind_table_edit | |
83 | { | |
84 | tic6x_unwind_edit_type type; | |
85 | /* Note: we sometimes want to insert an unwind entry corresponding to a | |
86 | section different from the one we're currently writing out, so record the | |
87 | (text) section this edit relates to here. */ | |
88 | asection *linked_section; | |
89 | unsigned int index; | |
90 | struct tic6x_unwind_table_edit *next; | |
91 | } | |
92 | tic6x_unwind_table_edit; | |
93 | ||
94 | typedef struct _tic6x_elf_section_data | |
95 | { | |
96 | /* Information about mapping symbols. */ | |
97 | struct bfd_elf_section_data elf; | |
98 | /* Information about unwind tables. */ | |
99 | union | |
100 | { | |
101 | /* Unwind info attached to a text section. */ | |
102 | struct | |
103 | { | |
104 | asection *tic6x_exidx_sec; | |
105 | } text; | |
106 | ||
107 | /* Unwind info attached to an .c6xabi.exidx section. */ | |
108 | struct | |
109 | { | |
110 | tic6x_unwind_table_edit *unwind_edit_list; | |
111 | tic6x_unwind_table_edit *unwind_edit_tail; | |
112 | } exidx; | |
113 | } u; | |
114 | } | |
115 | _tic6x_elf_section_data; | |
116 | ||
117 | #define elf32_tic6x_section_data(sec) \ | |
118 | ((_tic6x_elf_section_data *) elf_section_data (sec)) | |
119 | ||
41820509 JM |
120 | struct elf32_tic6x_obj_tdata |
121 | { | |
122 | struct elf_obj_tdata root; | |
123 | ||
124 | /* Whether to use RELA relocations when generating relocations. | |
125 | This is a per-object flag to allow the assembler to generate REL | |
126 | relocations for use in linker testcases. */ | |
127 | bfd_boolean use_rela_p; | |
128 | }; | |
129 | ||
130 | #define elf32_tic6x_tdata(abfd) \ | |
131 | ((struct elf32_tic6x_obj_tdata *) (abfd)->tdata.any) | |
40b36596 | 132 | |
ac145307 BS |
133 | #define is_tic6x_elf(bfd) \ |
134 | (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ | |
135 | && elf_tdata (bfd) != NULL \ | |
136 | && elf_object_id (bfd) == TIC6X_ELF_DATA) | |
137 | ||
138 | /* C6X ELF uses two common sections. One is the usual one, and the | |
139 | other is for small objects. All the small objects are kept | |
140 | together, and then referenced via the gp pointer, which yields | |
141 | faster assembler code. This is what we use for the small common | |
142 | section. This approach is copied from ecoff.c. */ | |
143 | static asection tic6x_elf_scom_section; | |
144 | static asymbol tic6x_elf_scom_symbol; | |
145 | static asymbol *tic6x_elf_scom_symbol_ptr; | |
146 | ||
40b36596 JM |
147 | static reloc_howto_type elf32_tic6x_howto_table[] = |
148 | { | |
149 | HOWTO (R_C6000_NONE, /* type */ | |
150 | 0, /* rightshift */ | |
6346d5ca | 151 | 3, /* size (0 = byte, 1 = short, 2 = long) */ |
40b36596 JM |
152 | 0, /* bitsize */ |
153 | FALSE, /* pc_relative */ | |
154 | 0, /* bitpos */ | |
155 | complain_overflow_dont,/* complain_on_overflow */ | |
156 | bfd_elf_generic_reloc, /* special_function */ | |
157 | "R_C6000_NONE", /* name */ | |
41820509 JM |
158 | FALSE, /* partial_inplace */ |
159 | 0, /* src_mask */ | |
160 | 0, /* dst_mask */ | |
161 | FALSE), /* pcrel_offset */ | |
162 | HOWTO (R_C6000_ABS32, /* type */ | |
163 | 0, /* rightshift */ | |
164 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
165 | 32, /* bitsize */ | |
166 | FALSE, /* pc_relative */ | |
167 | 0, /* bitpos */ | |
168 | complain_overflow_dont,/* complain_on_overflow */ | |
169 | bfd_elf_generic_reloc, /* special_function */ | |
170 | "R_C6000_ABS32", /* name */ | |
171 | FALSE, /* partial_inplace */ | |
172 | 0, /* src_mask */ | |
173 | 0xffffffff, /* dst_mask */ | |
174 | FALSE), /* pcrel_offset */ | |
175 | HOWTO (R_C6000_ABS16, /* type */ | |
176 | 0, /* rightshift */ | |
177 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
178 | 16, /* bitsize */ | |
179 | FALSE, /* pc_relative */ | |
180 | 0, /* bitpos */ | |
181 | complain_overflow_bitfield,/* complain_on_overflow */ | |
182 | bfd_elf_generic_reloc, /* special_function */ | |
183 | "R_C6000_ABS16", /* name */ | |
184 | FALSE, /* partial_inplace */ | |
185 | 0, /* src_mask */ | |
186 | 0x0000ffff, /* dst_mask */ | |
187 | FALSE), /* pcrel_offset */ | |
188 | HOWTO (R_C6000_ABS8, /* type */ | |
189 | 0, /* rightshift */ | |
190 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
191 | 8, /* bitsize */ | |
192 | FALSE, /* pc_relative */ | |
193 | 0, /* bitpos */ | |
194 | complain_overflow_bitfield,/* complain_on_overflow */ | |
195 | bfd_elf_generic_reloc, /* special_function */ | |
196 | "R_C6000_ABS8", /* name */ | |
197 | FALSE, /* partial_inplace */ | |
198 | 0, /* src_mask */ | |
199 | 0x000000ff, /* dst_mask */ | |
200 | FALSE), /* pcrel_offset */ | |
201 | HOWTO (R_C6000_PCR_S21, /* type */ | |
202 | 2, /* rightshift */ | |
203 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
204 | 21, /* bitsize */ | |
205 | TRUE, /* pc_relative */ | |
206 | 7, /* bitpos */ | |
207 | complain_overflow_signed,/* complain_on_overflow */ | |
208 | bfd_elf_generic_reloc, /* special_function */ | |
209 | "R_C6000_PCR_S21", /* name */ | |
210 | FALSE, /* partial_inplace */ | |
211 | 0, /* src_mask */ | |
212 | 0x0fffff80, /* dst_mask */ | |
213 | TRUE), /* pcrel_offset */ | |
214 | HOWTO (R_C6000_PCR_S12, /* type */ | |
215 | 2, /* rightshift */ | |
216 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
217 | 12, /* bitsize */ | |
218 | TRUE, /* pc_relative */ | |
219 | 16, /* bitpos */ | |
220 | complain_overflow_signed,/* complain_on_overflow */ | |
221 | bfd_elf_generic_reloc, /* special_function */ | |
222 | "R_C6000_PCR_S12", /* name */ | |
223 | FALSE, /* partial_inplace */ | |
224 | 0, /* src_mask */ | |
225 | 0x0fff0000, /* dst_mask */ | |
226 | TRUE), /* pcrel_offset */ | |
227 | HOWTO (R_C6000_PCR_S10, /* type */ | |
228 | 2, /* rightshift */ | |
229 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
230 | 10, /* bitsize */ | |
231 | TRUE, /* pc_relative */ | |
232 | 13, /* bitpos */ | |
233 | complain_overflow_signed,/* complain_on_overflow */ | |
234 | bfd_elf_generic_reloc, /* special_function */ | |
235 | "R_C6000_PCR_S10", /* name */ | |
236 | FALSE, /* partial_inplace */ | |
237 | 0, /* src_mask */ | |
238 | 0x007fe000, /* dst_mask */ | |
239 | TRUE), /* pcrel_offset */ | |
240 | HOWTO (R_C6000_PCR_S7, /* type */ | |
241 | 2, /* rightshift */ | |
242 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
243 | 7, /* bitsize */ | |
244 | TRUE, /* pc_relative */ | |
245 | 16, /* bitpos */ | |
246 | complain_overflow_signed,/* complain_on_overflow */ | |
247 | bfd_elf_generic_reloc, /* special_function */ | |
248 | "R_C6000_PCR_S7", /* name */ | |
249 | FALSE, /* partial_inplace */ | |
250 | 0, /* src_mask */ | |
251 | 0x007f0000, /* dst_mask */ | |
252 | TRUE), /* pcrel_offset */ | |
253 | HOWTO (R_C6000_ABS_S16, /* type */ | |
254 | 0, /* rightshift */ | |
255 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
256 | 16, /* bitsize */ | |
257 | FALSE, /* pc_relative */ | |
258 | 7, /* bitpos */ | |
259 | complain_overflow_signed,/* complain_on_overflow */ | |
260 | bfd_elf_generic_reloc, /* special_function */ | |
261 | "R_C6000_ABS_S16", /* name */ | |
262 | FALSE, /* partial_inplace */ | |
263 | 0, /* src_mask */ | |
264 | 0x007fff80, /* dst_mask */ | |
265 | FALSE), /* pcrel_offset */ | |
266 | HOWTO (R_C6000_ABS_L16, /* type */ | |
267 | 0, /* rightshift */ | |
268 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
269 | 16, /* bitsize */ | |
270 | FALSE, /* pc_relative */ | |
271 | 7, /* bitpos */ | |
272 | complain_overflow_dont,/* complain_on_overflow */ | |
273 | bfd_elf_generic_reloc, /* special_function */ | |
274 | "R_C6000_ABS_L16", /* name */ | |
275 | FALSE, /* partial_inplace */ | |
276 | 0, /* src_mask */ | |
277 | 0x007fff80, /* dst_mask */ | |
278 | FALSE), /* pcrel_offset */ | |
279 | HOWTO (R_C6000_ABS_H16, /* type */ | |
280 | 16, /* rightshift */ | |
281 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
282 | 16, /* bitsize */ | |
283 | FALSE, /* pc_relative */ | |
284 | 7, /* bitpos */ | |
285 | complain_overflow_dont,/* complain_on_overflow */ | |
286 | bfd_elf_generic_reloc, /* special_function */ | |
287 | "R_C6000_ABS_H16", /* name */ | |
288 | FALSE, /* partial_inplace */ | |
289 | 0, /* src_mask */ | |
290 | 0x007fff80, /* dst_mask */ | |
291 | FALSE), /* pcrel_offset */ | |
292 | HOWTO (R_C6000_SBR_U15_B, /* type */ | |
293 | 0, /* rightshift */ | |
294 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
295 | 15, /* bitsize */ | |
296 | FALSE, /* pc_relative */ | |
297 | 8, /* bitpos */ | |
298 | complain_overflow_unsigned,/* complain_on_overflow */ | |
299 | bfd_elf_generic_reloc, /* special_function */ | |
300 | "R_C6000_SBR_U15_B", /* name */ | |
301 | FALSE, /* partial_inplace */ | |
302 | 0, /* src_mask */ | |
303 | 0x007fff00, /* dst_mask */ | |
304 | FALSE), /* pcrel_offset */ | |
305 | HOWTO (R_C6000_SBR_U15_H, /* type */ | |
306 | 1, /* rightshift */ | |
307 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
308 | 15, /* bitsize */ | |
309 | FALSE, /* pc_relative */ | |
310 | 8, /* bitpos */ | |
311 | complain_overflow_unsigned,/* complain_on_overflow */ | |
312 | bfd_elf_generic_reloc, /* special_function */ | |
313 | "R_C6000_SBR_U15_H", /* name */ | |
314 | FALSE, /* partial_inplace */ | |
315 | 0, /* src_mask */ | |
316 | 0x007fff00, /* dst_mask */ | |
317 | FALSE), /* pcrel_offset */ | |
318 | HOWTO (R_C6000_SBR_U15_W, /* type */ | |
319 | 2, /* rightshift */ | |
320 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
321 | 15, /* bitsize */ | |
322 | FALSE, /* pc_relative */ | |
323 | 8, /* bitpos */ | |
324 | complain_overflow_unsigned,/* complain_on_overflow */ | |
325 | bfd_elf_generic_reloc, /* special_function */ | |
326 | "R_C6000_SBR_U15_W", /* name */ | |
327 | FALSE, /* partial_inplace */ | |
328 | 0, /* src_mask */ | |
329 | 0x007fff00, /* dst_mask */ | |
330 | FALSE), /* pcrel_offset */ | |
331 | HOWTO (R_C6000_SBR_S16, /* type */ | |
332 | 0, /* rightshift */ | |
333 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
334 | 16, /* bitsize */ | |
335 | FALSE, /* pc_relative */ | |
336 | 7, /* bitpos */ | |
337 | complain_overflow_signed,/* complain_on_overflow */ | |
338 | bfd_elf_generic_reloc, /* special_function */ | |
339 | "R_C6000_SBR_S16", /* name */ | |
340 | FALSE, /* partial_inplace */ | |
341 | 0, /* src_mask */ | |
342 | 0x007fff80, /* dst_mask */ | |
343 | FALSE), /* pcrel_offset */ | |
344 | HOWTO (R_C6000_SBR_L16_B, /* type */ | |
345 | 0, /* rightshift */ | |
346 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
347 | 16, /* bitsize */ | |
348 | FALSE, /* pc_relative */ | |
349 | 7, /* bitpos */ | |
350 | complain_overflow_dont,/* complain_on_overflow */ | |
351 | bfd_elf_generic_reloc, /* special_function */ | |
352 | "R_C6000_SBR_L16_B", /* name */ | |
353 | FALSE, /* partial_inplace */ | |
354 | 0, /* src_mask */ | |
355 | 0x007fff80, /* dst_mask */ | |
356 | FALSE), /* pcrel_offset */ | |
357 | HOWTO (R_C6000_SBR_L16_H, /* type */ | |
358 | 1, /* rightshift */ | |
359 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
360 | 16, /* bitsize */ | |
361 | FALSE, /* pc_relative */ | |
362 | 7, /* bitpos */ | |
363 | complain_overflow_dont,/* complain_on_overflow */ | |
364 | bfd_elf_generic_reloc, /* special_function */ | |
365 | "R_C6000_SBR_L16_H", /* name */ | |
366 | FALSE, /* partial_inplace */ | |
367 | 0, /* src_mask */ | |
368 | 0x007fff80, /* dst_mask */ | |
369 | FALSE), /* pcrel_offset */ | |
370 | HOWTO (R_C6000_SBR_L16_W, /* type */ | |
371 | 2, /* rightshift */ | |
372 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
373 | 16, /* bitsize */ | |
374 | FALSE, /* pc_relative */ | |
375 | 7, /* bitpos */ | |
376 | complain_overflow_dont,/* complain_on_overflow */ | |
377 | bfd_elf_generic_reloc, /* special_function */ | |
378 | "R_C6000_SBR_L16_W", /* name */ | |
379 | FALSE, /* partial_inplace */ | |
380 | 0, /* src_mask */ | |
381 | 0x007fff80, /* dst_mask */ | |
382 | FALSE), /* pcrel_offset */ | |
383 | HOWTO (R_C6000_SBR_H16_B, /* type */ | |
384 | 16, /* rightshift */ | |
385 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
386 | 16, /* bitsize */ | |
387 | FALSE, /* pc_relative */ | |
388 | 7, /* bitpos */ | |
389 | complain_overflow_dont,/* complain_on_overflow */ | |
390 | bfd_elf_generic_reloc, /* special_function */ | |
391 | "R_C6000_SBR_H16_B", /* name */ | |
392 | FALSE, /* partial_inplace */ | |
393 | 0, /* src_mask */ | |
394 | 0x007fff80, /* dst_mask */ | |
395 | FALSE), /* pcrel_offset */ | |
396 | HOWTO (R_C6000_SBR_H16_H, /* type */ | |
397 | 17, /* rightshift */ | |
398 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
399 | 16, /* bitsize */ | |
400 | FALSE, /* pc_relative */ | |
401 | 7, /* bitpos */ | |
402 | complain_overflow_dont,/* complain_on_overflow */ | |
403 | bfd_elf_generic_reloc, /* special_function */ | |
404 | "R_C6000_SBR_H16_H", /* name */ | |
405 | FALSE, /* partial_inplace */ | |
406 | 0, /* src_mask */ | |
407 | 0x007fff80, /* dst_mask */ | |
408 | FALSE), /* pcrel_offset */ | |
409 | HOWTO (R_C6000_SBR_H16_W, /* type */ | |
410 | 18, /* rightshift */ | |
411 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
412 | 16, /* bitsize */ | |
413 | FALSE, /* pc_relative */ | |
414 | 7, /* bitpos */ | |
415 | complain_overflow_dont,/* complain_on_overflow */ | |
416 | bfd_elf_generic_reloc, /* special_function */ | |
417 | "R_C6000_SBR_H16_W", /* name */ | |
418 | FALSE, /* partial_inplace */ | |
419 | 0, /* src_mask */ | |
420 | 0x007fff80, /* dst_mask */ | |
421 | FALSE), /* pcrel_offset */ | |
422 | HOWTO (R_C6000_SBR_GOT_U15_W, /* type */ | |
423 | 2, /* rightshift */ | |
424 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
425 | 15, /* bitsize */ | |
426 | FALSE, /* pc_relative */ | |
427 | 8, /* bitpos */ | |
428 | complain_overflow_unsigned,/* complain_on_overflow */ | |
429 | bfd_elf_generic_reloc, /* special_function */ | |
430 | "R_C6000_SBR_GOT_U15_W",/* name */ | |
431 | FALSE, /* partial_inplace */ | |
432 | 0, /* src_mask */ | |
433 | 0x007fff00, /* dst_mask */ | |
434 | FALSE), /* pcrel_offset */ | |
435 | HOWTO (R_C6000_SBR_GOT_L16_W, /* type */ | |
436 | 2, /* rightshift */ | |
437 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
438 | 16, /* bitsize */ | |
439 | FALSE, /* pc_relative */ | |
440 | 7, /* bitpos */ | |
441 | complain_overflow_dont,/* complain_on_overflow */ | |
442 | bfd_elf_generic_reloc, /* special_function */ | |
443 | "R_C6000_SBR_GOT_L16_W",/* name */ | |
444 | FALSE, /* partial_inplace */ | |
445 | 0, /* src_mask */ | |
446 | 0x007fff80, /* dst_mask */ | |
447 | FALSE), /* pcrel_offset */ | |
448 | HOWTO (R_C6000_SBR_GOT_H16_W, /* type */ | |
449 | 18, /* rightshift */ | |
450 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
451 | 16, /* bitsize */ | |
452 | FALSE, /* pc_relative */ | |
453 | 7, /* bitpos */ | |
454 | complain_overflow_dont,/* complain_on_overflow */ | |
455 | bfd_elf_generic_reloc, /* special_function */ | |
456 | "R_C6000_SBR_GOT_H16_W",/* name */ | |
457 | FALSE, /* partial_inplace */ | |
458 | 0, /* src_mask */ | |
459 | 0x007fff80, /* dst_mask */ | |
460 | FALSE), /* pcrel_offset */ | |
461 | HOWTO (R_C6000_DSBT_INDEX, /* type */ | |
462 | 0, /* rightshift */ | |
463 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
464 | 15, /* bitsize */ | |
465 | FALSE, /* pc_relative */ | |
466 | 8, /* bitpos */ | |
467 | complain_overflow_unsigned,/* complain_on_overflow */ | |
468 | bfd_elf_generic_reloc, /* special_function */ | |
469 | "R_C6000_DSBT_INDEX", /* name */ | |
470 | FALSE, /* partial_inplace */ | |
471 | 0, /* src_mask */ | |
472 | 0x007fff00, /* dst_mask */ | |
473 | FALSE), /* pcrel_offset */ | |
474 | HOWTO (R_C6000_PREL31, /* type */ | |
475 | 1, /* rightshift */ | |
476 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
477 | 31, /* bitsize */ | |
44e87ece | 478 | TRUE, /* pc_relative */ |
41820509 JM |
479 | 0, /* bitpos */ |
480 | complain_overflow_dont,/* complain_on_overflow */ | |
481 | bfd_elf_generic_reloc, /* special_function */ | |
482 | "R_C6000_PREL31", /* name */ | |
483 | FALSE, /* partial_inplace */ | |
484 | 0, /* src_mask */ | |
485 | 0x7fffffff, /* dst_mask */ | |
44e87ece | 486 | TRUE), /* pcrel_offset */ |
41820509 JM |
487 | HOWTO (R_C6000_COPY, /* type */ |
488 | 0, /* rightshift */ | |
489 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
490 | 32, /* bitsize */ | |
491 | FALSE, /* pc_relative */ | |
492 | 0, /* bitpos */ | |
493 | complain_overflow_dont,/* complain_on_overflow */ | |
494 | bfd_elf_generic_reloc, /* special_function */ | |
495 | "R_C6000_COPY", /* name */ | |
496 | FALSE, /* partial_inplace */ | |
497 | 0, /* src_mask */ | |
498 | 0xffffffff, /* dst_mask */ | |
499 | FALSE), /* pcrel_offset */ | |
ac145307 BS |
500 | HOWTO (R_C6000_JUMP_SLOT, /* type */ |
501 | 0, /* rightshift */ | |
502 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
503 | 32, /* bitsize */ | |
504 | FALSE, /* pc_relative */ | |
505 | 0, /* bitpos */ | |
506 | complain_overflow_dont,/* complain_on_overflow */ | |
507 | bfd_elf_generic_reloc, /* special_function */ | |
508 | "R_C6000_JUMP_SLOT", /* name */ | |
509 | FALSE, /* partial_inplace */ | |
510 | 0, /* src_mask */ | |
511 | 0xffffffff, /* dst_mask */ | |
512 | FALSE), /* pcrel_offset */ | |
2fbb87f6 PB |
513 | HOWTO (R_C6000_EHTYPE, /* type */ |
514 | 0, /* rightshift */ | |
515 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
516 | 32, /* bitsize */ | |
517 | FALSE, /* pc_relative */ | |
518 | 0, /* bitpos */ | |
519 | complain_overflow_dont,/* complain_on_overflow */ | |
520 | bfd_elf_generic_reloc, /* special_function */ | |
521 | "R_C6000_EHTYPE", /* name */ | |
522 | FALSE, /* partial_inplace */ | |
523 | 0, /* src_mask */ | |
524 | 0xffffffff, /* dst_mask */ | |
525 | FALSE), /* pcrel_offset */ | |
4a732032 BS |
526 | HOWTO (R_C6000_PCR_H16, /* type */ |
527 | 16, /* rightshift */ | |
528 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
529 | 16, /* bitsize */ | |
530 | TRUE, /* pc_relative */ | |
531 | 7, /* bitpos */ | |
532 | complain_overflow_dont,/* complain_on_overflow */ | |
533 | bfd_elf_generic_reloc, /* special_function */ | |
534 | "R_C6000_PCR_H16", /* name */ | |
535 | FALSE, /* partial_inplace */ | |
536 | 0, /* src_mask */ | |
537 | 0x007fff80, /* dst_mask */ | |
538 | TRUE), /* pcrel_offset */ | |
539 | HOWTO (R_C6000_PCR_L16, /* type */ | |
540 | 0, /* rightshift */ | |
541 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
542 | 16, /* bitsize */ | |
543 | TRUE, /* pc_relative */ | |
544 | 7, /* bitpos */ | |
545 | complain_overflow_dont,/* complain_on_overflow */ | |
546 | bfd_elf_generic_reloc, /* special_function */ | |
547 | "R_C6000_PCR_L16", /* name */ | |
548 | FALSE, /* partial_inplace */ | |
549 | 0, /* src_mask */ | |
550 | 0x007fff80, /* dst_mask */ | |
551 | TRUE), /* pcrel_offset */ | |
41820509 JM |
552 | EMPTY_HOWTO (31), |
553 | EMPTY_HOWTO (32), | |
554 | EMPTY_HOWTO (33), | |
555 | EMPTY_HOWTO (34), | |
556 | EMPTY_HOWTO (35), | |
557 | EMPTY_HOWTO (36), | |
558 | EMPTY_HOWTO (37), | |
559 | EMPTY_HOWTO (38), | |
560 | EMPTY_HOWTO (39), | |
561 | EMPTY_HOWTO (40), | |
562 | EMPTY_HOWTO (41), | |
563 | EMPTY_HOWTO (42), | |
564 | EMPTY_HOWTO (43), | |
565 | EMPTY_HOWTO (44), | |
566 | EMPTY_HOWTO (45), | |
567 | EMPTY_HOWTO (46), | |
568 | EMPTY_HOWTO (47), | |
569 | EMPTY_HOWTO (48), | |
570 | EMPTY_HOWTO (49), | |
571 | EMPTY_HOWTO (50), | |
572 | EMPTY_HOWTO (51), | |
573 | EMPTY_HOWTO (52), | |
574 | EMPTY_HOWTO (53), | |
575 | EMPTY_HOWTO (54), | |
576 | EMPTY_HOWTO (55), | |
577 | EMPTY_HOWTO (56), | |
578 | EMPTY_HOWTO (57), | |
579 | EMPTY_HOWTO (58), | |
580 | EMPTY_HOWTO (59), | |
581 | EMPTY_HOWTO (60), | |
582 | EMPTY_HOWTO (61), | |
583 | EMPTY_HOWTO (62), | |
584 | EMPTY_HOWTO (63), | |
585 | EMPTY_HOWTO (64), | |
586 | EMPTY_HOWTO (65), | |
587 | EMPTY_HOWTO (66), | |
588 | EMPTY_HOWTO (67), | |
589 | EMPTY_HOWTO (68), | |
590 | EMPTY_HOWTO (69), | |
591 | EMPTY_HOWTO (70), | |
592 | EMPTY_HOWTO (71), | |
593 | EMPTY_HOWTO (72), | |
594 | EMPTY_HOWTO (73), | |
595 | EMPTY_HOWTO (74), | |
596 | EMPTY_HOWTO (75), | |
597 | EMPTY_HOWTO (76), | |
598 | EMPTY_HOWTO (77), | |
599 | EMPTY_HOWTO (78), | |
600 | EMPTY_HOWTO (79), | |
601 | EMPTY_HOWTO (80), | |
602 | EMPTY_HOWTO (81), | |
603 | EMPTY_HOWTO (82), | |
604 | EMPTY_HOWTO (83), | |
605 | EMPTY_HOWTO (84), | |
606 | EMPTY_HOWTO (85), | |
607 | EMPTY_HOWTO (86), | |
608 | EMPTY_HOWTO (87), | |
609 | EMPTY_HOWTO (88), | |
610 | EMPTY_HOWTO (89), | |
611 | EMPTY_HOWTO (90), | |
612 | EMPTY_HOWTO (91), | |
613 | EMPTY_HOWTO (92), | |
614 | EMPTY_HOWTO (93), | |
615 | EMPTY_HOWTO (94), | |
616 | EMPTY_HOWTO (95), | |
617 | EMPTY_HOWTO (96), | |
618 | EMPTY_HOWTO (97), | |
619 | EMPTY_HOWTO (98), | |
620 | EMPTY_HOWTO (99), | |
621 | EMPTY_HOWTO (100), | |
622 | EMPTY_HOWTO (101), | |
623 | EMPTY_HOWTO (102), | |
624 | EMPTY_HOWTO (103), | |
625 | EMPTY_HOWTO (104), | |
626 | EMPTY_HOWTO (105), | |
627 | EMPTY_HOWTO (106), | |
628 | EMPTY_HOWTO (107), | |
629 | EMPTY_HOWTO (108), | |
630 | EMPTY_HOWTO (109), | |
631 | EMPTY_HOWTO (110), | |
632 | EMPTY_HOWTO (111), | |
633 | EMPTY_HOWTO (112), | |
634 | EMPTY_HOWTO (113), | |
635 | EMPTY_HOWTO (114), | |
636 | EMPTY_HOWTO (115), | |
637 | EMPTY_HOWTO (116), | |
638 | EMPTY_HOWTO (117), | |
639 | EMPTY_HOWTO (118), | |
640 | EMPTY_HOWTO (119), | |
641 | EMPTY_HOWTO (120), | |
642 | EMPTY_HOWTO (121), | |
643 | EMPTY_HOWTO (122), | |
644 | EMPTY_HOWTO (123), | |
645 | EMPTY_HOWTO (124), | |
646 | EMPTY_HOWTO (125), | |
647 | EMPTY_HOWTO (126), | |
648 | EMPTY_HOWTO (127), | |
649 | EMPTY_HOWTO (128), | |
650 | EMPTY_HOWTO (129), | |
651 | EMPTY_HOWTO (130), | |
652 | EMPTY_HOWTO (131), | |
653 | EMPTY_HOWTO (132), | |
654 | EMPTY_HOWTO (133), | |
655 | EMPTY_HOWTO (134), | |
656 | EMPTY_HOWTO (135), | |
657 | EMPTY_HOWTO (136), | |
658 | EMPTY_HOWTO (137), | |
659 | EMPTY_HOWTO (138), | |
660 | EMPTY_HOWTO (139), | |
661 | EMPTY_HOWTO (140), | |
662 | EMPTY_HOWTO (141), | |
663 | EMPTY_HOWTO (142), | |
664 | EMPTY_HOWTO (143), | |
665 | EMPTY_HOWTO (144), | |
666 | EMPTY_HOWTO (145), | |
667 | EMPTY_HOWTO (146), | |
668 | EMPTY_HOWTO (147), | |
669 | EMPTY_HOWTO (148), | |
670 | EMPTY_HOWTO (149), | |
671 | EMPTY_HOWTO (150), | |
672 | EMPTY_HOWTO (151), | |
673 | EMPTY_HOWTO (152), | |
674 | EMPTY_HOWTO (153), | |
675 | EMPTY_HOWTO (154), | |
676 | EMPTY_HOWTO (155), | |
677 | EMPTY_HOWTO (156), | |
678 | EMPTY_HOWTO (157), | |
679 | EMPTY_HOWTO (158), | |
680 | EMPTY_HOWTO (159), | |
681 | EMPTY_HOWTO (160), | |
682 | EMPTY_HOWTO (161), | |
683 | EMPTY_HOWTO (162), | |
684 | EMPTY_HOWTO (163), | |
685 | EMPTY_HOWTO (164), | |
686 | EMPTY_HOWTO (165), | |
687 | EMPTY_HOWTO (166), | |
688 | EMPTY_HOWTO (167), | |
689 | EMPTY_HOWTO (168), | |
690 | EMPTY_HOWTO (169), | |
691 | EMPTY_HOWTO (170), | |
692 | EMPTY_HOWTO (171), | |
693 | EMPTY_HOWTO (172), | |
694 | EMPTY_HOWTO (173), | |
695 | EMPTY_HOWTO (174), | |
696 | EMPTY_HOWTO (175), | |
697 | EMPTY_HOWTO (176), | |
698 | EMPTY_HOWTO (177), | |
699 | EMPTY_HOWTO (178), | |
700 | EMPTY_HOWTO (179), | |
701 | EMPTY_HOWTO (180), | |
702 | EMPTY_HOWTO (181), | |
703 | EMPTY_HOWTO (182), | |
704 | EMPTY_HOWTO (183), | |
705 | EMPTY_HOWTO (184), | |
706 | EMPTY_HOWTO (185), | |
707 | EMPTY_HOWTO (186), | |
708 | EMPTY_HOWTO (187), | |
709 | EMPTY_HOWTO (188), | |
710 | EMPTY_HOWTO (189), | |
711 | EMPTY_HOWTO (190), | |
712 | EMPTY_HOWTO (191), | |
713 | EMPTY_HOWTO (192), | |
714 | EMPTY_HOWTO (193), | |
715 | EMPTY_HOWTO (194), | |
716 | EMPTY_HOWTO (195), | |
717 | EMPTY_HOWTO (196), | |
718 | EMPTY_HOWTO (197), | |
719 | EMPTY_HOWTO (198), | |
720 | EMPTY_HOWTO (199), | |
721 | EMPTY_HOWTO (200), | |
722 | EMPTY_HOWTO (201), | |
723 | EMPTY_HOWTO (202), | |
724 | EMPTY_HOWTO (203), | |
725 | EMPTY_HOWTO (204), | |
726 | EMPTY_HOWTO (205), | |
727 | EMPTY_HOWTO (206), | |
728 | EMPTY_HOWTO (207), | |
729 | EMPTY_HOWTO (208), | |
730 | EMPTY_HOWTO (209), | |
731 | EMPTY_HOWTO (210), | |
732 | EMPTY_HOWTO (211), | |
733 | EMPTY_HOWTO (212), | |
734 | EMPTY_HOWTO (213), | |
735 | EMPTY_HOWTO (214), | |
736 | EMPTY_HOWTO (215), | |
737 | EMPTY_HOWTO (216), | |
738 | EMPTY_HOWTO (217), | |
739 | EMPTY_HOWTO (218), | |
740 | EMPTY_HOWTO (219), | |
741 | EMPTY_HOWTO (220), | |
742 | EMPTY_HOWTO (221), | |
743 | EMPTY_HOWTO (222), | |
744 | EMPTY_HOWTO (223), | |
745 | EMPTY_HOWTO (224), | |
746 | EMPTY_HOWTO (225), | |
747 | EMPTY_HOWTO (226), | |
748 | EMPTY_HOWTO (227), | |
749 | EMPTY_HOWTO (228), | |
750 | EMPTY_HOWTO (229), | |
751 | EMPTY_HOWTO (230), | |
752 | EMPTY_HOWTO (231), | |
753 | EMPTY_HOWTO (232), | |
754 | EMPTY_HOWTO (233), | |
755 | EMPTY_HOWTO (234), | |
756 | EMPTY_HOWTO (235), | |
757 | EMPTY_HOWTO (236), | |
758 | EMPTY_HOWTO (237), | |
759 | EMPTY_HOWTO (238), | |
760 | EMPTY_HOWTO (239), | |
761 | EMPTY_HOWTO (240), | |
762 | EMPTY_HOWTO (241), | |
763 | EMPTY_HOWTO (242), | |
764 | EMPTY_HOWTO (243), | |
765 | EMPTY_HOWTO (244), | |
766 | EMPTY_HOWTO (245), | |
767 | EMPTY_HOWTO (246), | |
768 | EMPTY_HOWTO (247), | |
769 | EMPTY_HOWTO (248), | |
770 | EMPTY_HOWTO (249), | |
771 | EMPTY_HOWTO (250), | |
772 | EMPTY_HOWTO (251), | |
773 | EMPTY_HOWTO (252), | |
774 | HOWTO (R_C6000_ALIGN, /* type */ | |
775 | 0, /* rightshift */ | |
776 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
777 | 0, /* bitsize */ | |
778 | FALSE, /* pc_relative */ | |
779 | 0, /* bitpos */ | |
780 | complain_overflow_dont,/* complain_on_overflow */ | |
781 | bfd_elf_generic_reloc, /* special_function */ | |
782 | "R_C6000_ALIGN", /* name */ | |
783 | FALSE, /* partial_inplace */ | |
784 | 0, /* src_mask */ | |
785 | 0, /* dst_mask */ | |
786 | FALSE), /* pcrel_offset */ | |
787 | HOWTO (R_C6000_FPHEAD, /* type */ | |
788 | 0, /* rightshift */ | |
789 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
790 | 0, /* bitsize */ | |
791 | FALSE, /* pc_relative */ | |
792 | 0, /* bitpos */ | |
793 | complain_overflow_dont,/* complain_on_overflow */ | |
794 | bfd_elf_generic_reloc, /* special_function */ | |
795 | "R_C6000_FPHEAD", /* name */ | |
796 | FALSE, /* partial_inplace */ | |
797 | 0, /* src_mask */ | |
798 | 0, /* dst_mask */ | |
799 | FALSE), /* pcrel_offset */ | |
800 | HOWTO (R_C6000_NOCMP, /* type */ | |
801 | 0, /* rightshift */ | |
802 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
803 | 0, /* bitsize */ | |
804 | FALSE, /* pc_relative */ | |
805 | 0, /* bitpos */ | |
806 | complain_overflow_dont,/* complain_on_overflow */ | |
807 | bfd_elf_generic_reloc, /* special_function */ | |
808 | "R_C6000_NOCMP", /* name */ | |
809 | FALSE, /* partial_inplace */ | |
810 | 0, /* src_mask */ | |
811 | 0, /* dst_mask */ | |
812 | FALSE) /* pcrel_offset */ | |
813 | }; | |
814 | ||
815 | static reloc_howto_type elf32_tic6x_howto_table_rel[] = | |
816 | { | |
817 | HOWTO (R_C6000_NONE, /* type */ | |
818 | 0, /* rightshift */ | |
6346d5ca | 819 | 3, /* size (0 = byte, 1 = short, 2 = long) */ |
41820509 JM |
820 | 0, /* bitsize */ |
821 | FALSE, /* pc_relative */ | |
822 | 0, /* bitpos */ | |
823 | complain_overflow_dont,/* complain_on_overflow */ | |
824 | bfd_elf_generic_reloc, /* special_function */ | |
825 | "R_C6000_NONE", /* name */ | |
826 | TRUE, /* partial_inplace */ | |
40b36596 JM |
827 | 0, /* src_mask */ |
828 | 0, /* dst_mask */ | |
829 | FALSE), /* pcrel_offset */ | |
830 | HOWTO (R_C6000_ABS32, /* type */ | |
831 | 0, /* rightshift */ | |
832 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
833 | 32, /* bitsize */ | |
834 | FALSE, /* pc_relative */ | |
835 | 0, /* bitpos */ | |
836 | complain_overflow_dont,/* complain_on_overflow */ | |
837 | bfd_elf_generic_reloc, /* special_function */ | |
838 | "R_C6000_ABS32", /* name */ | |
41820509 JM |
839 | TRUE, /* partial_inplace */ |
840 | 0xffffffff, /* src_mask */ | |
40b36596 JM |
841 | 0xffffffff, /* dst_mask */ |
842 | FALSE), /* pcrel_offset */ | |
843 | HOWTO (R_C6000_ABS16, /* type */ | |
844 | 0, /* rightshift */ | |
845 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
846 | 16, /* bitsize */ | |
847 | FALSE, /* pc_relative */ | |
848 | 0, /* bitpos */ | |
849 | complain_overflow_bitfield,/* complain_on_overflow */ | |
850 | bfd_elf_generic_reloc, /* special_function */ | |
851 | "R_C6000_ABS16", /* name */ | |
41820509 JM |
852 | TRUE, /* partial_inplace */ |
853 | 0x0000ffff, /* src_mask */ | |
40b36596 JM |
854 | 0x0000ffff, /* dst_mask */ |
855 | FALSE), /* pcrel_offset */ | |
856 | HOWTO (R_C6000_ABS8, /* type */ | |
857 | 0, /* rightshift */ | |
858 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
859 | 8, /* bitsize */ | |
860 | FALSE, /* pc_relative */ | |
861 | 0, /* bitpos */ | |
862 | complain_overflow_bitfield,/* complain_on_overflow */ | |
863 | bfd_elf_generic_reloc, /* special_function */ | |
864 | "R_C6000_ABS8", /* name */ | |
41820509 JM |
865 | TRUE, /* partial_inplace */ |
866 | 0x000000ff, /* src_mask */ | |
40b36596 JM |
867 | 0x000000ff, /* dst_mask */ |
868 | FALSE), /* pcrel_offset */ | |
869 | HOWTO (R_C6000_PCR_S21, /* type */ | |
870 | 2, /* rightshift */ | |
871 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
872 | 21, /* bitsize */ | |
873 | TRUE, /* pc_relative */ | |
874 | 7, /* bitpos */ | |
875 | complain_overflow_signed,/* complain_on_overflow */ | |
876 | bfd_elf_generic_reloc, /* special_function */ | |
877 | "R_C6000_PCR_S21", /* name */ | |
41820509 JM |
878 | TRUE, /* partial_inplace */ |
879 | 0x0fffff80, /* src_mask */ | |
40b36596 JM |
880 | 0x0fffff80, /* dst_mask */ |
881 | TRUE), /* pcrel_offset */ | |
882 | HOWTO (R_C6000_PCR_S12, /* type */ | |
883 | 2, /* rightshift */ | |
884 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
885 | 12, /* bitsize */ | |
886 | TRUE, /* pc_relative */ | |
887 | 16, /* bitpos */ | |
888 | complain_overflow_signed,/* complain_on_overflow */ | |
889 | bfd_elf_generic_reloc, /* special_function */ | |
890 | "R_C6000_PCR_S12", /* name */ | |
41820509 JM |
891 | TRUE, /* partial_inplace */ |
892 | 0x0fff0000, /* src_mask */ | |
40b36596 JM |
893 | 0x0fff0000, /* dst_mask */ |
894 | TRUE), /* pcrel_offset */ | |
895 | HOWTO (R_C6000_PCR_S10, /* type */ | |
896 | 2, /* rightshift */ | |
897 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
898 | 10, /* bitsize */ | |
899 | TRUE, /* pc_relative */ | |
900 | 13, /* bitpos */ | |
901 | complain_overflow_signed,/* complain_on_overflow */ | |
902 | bfd_elf_generic_reloc, /* special_function */ | |
903 | "R_C6000_PCR_S10", /* name */ | |
41820509 JM |
904 | TRUE, /* partial_inplace */ |
905 | 0x007fe000, /* src_mask */ | |
40b36596 JM |
906 | 0x007fe000, /* dst_mask */ |
907 | TRUE), /* pcrel_offset */ | |
908 | HOWTO (R_C6000_PCR_S7, /* type */ | |
909 | 2, /* rightshift */ | |
910 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
911 | 7, /* bitsize */ | |
912 | TRUE, /* pc_relative */ | |
913 | 16, /* bitpos */ | |
914 | complain_overflow_signed,/* complain_on_overflow */ | |
915 | bfd_elf_generic_reloc, /* special_function */ | |
916 | "R_C6000_PCR_S7", /* name */ | |
41820509 JM |
917 | TRUE, /* partial_inplace */ |
918 | 0x007f0000, /* src_mask */ | |
40b36596 JM |
919 | 0x007f0000, /* dst_mask */ |
920 | TRUE), /* pcrel_offset */ | |
921 | HOWTO (R_C6000_ABS_S16, /* type */ | |
922 | 0, /* rightshift */ | |
923 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
924 | 16, /* bitsize */ | |
925 | FALSE, /* pc_relative */ | |
926 | 7, /* bitpos */ | |
927 | complain_overflow_signed,/* complain_on_overflow */ | |
928 | bfd_elf_generic_reloc, /* special_function */ | |
929 | "R_C6000_ABS_S16", /* name */ | |
41820509 JM |
930 | TRUE, /* partial_inplace */ |
931 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
932 | 0x007fff80, /* dst_mask */ |
933 | FALSE), /* pcrel_offset */ | |
934 | HOWTO (R_C6000_ABS_L16, /* type */ | |
935 | 0, /* rightshift */ | |
936 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
937 | 16, /* bitsize */ | |
938 | FALSE, /* pc_relative */ | |
939 | 7, /* bitpos */ | |
940 | complain_overflow_dont,/* complain_on_overflow */ | |
941 | bfd_elf_generic_reloc, /* special_function */ | |
942 | "R_C6000_ABS_L16", /* name */ | |
41820509 JM |
943 | TRUE, /* partial_inplace */ |
944 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
945 | 0x007fff80, /* dst_mask */ |
946 | FALSE), /* pcrel_offset */ | |
41820509 | 947 | EMPTY_HOWTO (R_C6000_ABS_H16), |
40b36596 JM |
948 | HOWTO (R_C6000_SBR_U15_B, /* type */ |
949 | 0, /* rightshift */ | |
950 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
951 | 15, /* bitsize */ | |
952 | FALSE, /* pc_relative */ | |
953 | 8, /* bitpos */ | |
954 | complain_overflow_unsigned,/* complain_on_overflow */ | |
955 | bfd_elf_generic_reloc, /* special_function */ | |
956 | "R_C6000_SBR_U15_B", /* name */ | |
41820509 JM |
957 | TRUE, /* partial_inplace */ |
958 | 0x007fff00, /* src_mask */ | |
40b36596 JM |
959 | 0x007fff00, /* dst_mask */ |
960 | FALSE), /* pcrel_offset */ | |
961 | HOWTO (R_C6000_SBR_U15_H, /* type */ | |
962 | 1, /* rightshift */ | |
963 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
964 | 15, /* bitsize */ | |
965 | FALSE, /* pc_relative */ | |
966 | 8, /* bitpos */ | |
967 | complain_overflow_unsigned,/* complain_on_overflow */ | |
968 | bfd_elf_generic_reloc, /* special_function */ | |
969 | "R_C6000_SBR_U15_H", /* name */ | |
41820509 JM |
970 | TRUE, /* partial_inplace */ |
971 | 0x007fff00, /* src_mask */ | |
40b36596 JM |
972 | 0x007fff00, /* dst_mask */ |
973 | FALSE), /* pcrel_offset */ | |
974 | HOWTO (R_C6000_SBR_U15_W, /* type */ | |
975 | 2, /* rightshift */ | |
976 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
977 | 15, /* bitsize */ | |
978 | FALSE, /* pc_relative */ | |
979 | 8, /* bitpos */ | |
980 | complain_overflow_unsigned,/* complain_on_overflow */ | |
981 | bfd_elf_generic_reloc, /* special_function */ | |
982 | "R_C6000_SBR_U15_W", /* name */ | |
41820509 JM |
983 | TRUE, /* partial_inplace */ |
984 | 0x007fff00, /* src_mask */ | |
40b36596 JM |
985 | 0x007fff00, /* dst_mask */ |
986 | FALSE), /* pcrel_offset */ | |
987 | HOWTO (R_C6000_SBR_S16, /* type */ | |
988 | 0, /* rightshift */ | |
989 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
990 | 16, /* bitsize */ | |
991 | FALSE, /* pc_relative */ | |
992 | 7, /* bitpos */ | |
993 | complain_overflow_signed,/* complain_on_overflow */ | |
994 | bfd_elf_generic_reloc, /* special_function */ | |
995 | "R_C6000_SBR_S16", /* name */ | |
41820509 JM |
996 | TRUE, /* partial_inplace */ |
997 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
998 | 0x007fff80, /* dst_mask */ |
999 | FALSE), /* pcrel_offset */ | |
1000 | HOWTO (R_C6000_SBR_L16_B, /* type */ | |
1001 | 0, /* rightshift */ | |
1002 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1003 | 16, /* bitsize */ | |
1004 | FALSE, /* pc_relative */ | |
1005 | 7, /* bitpos */ | |
1006 | complain_overflow_dont,/* complain_on_overflow */ | |
1007 | bfd_elf_generic_reloc, /* special_function */ | |
1008 | "R_C6000_SBR_L16_B", /* name */ | |
41820509 JM |
1009 | TRUE, /* partial_inplace */ |
1010 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
1011 | 0x007fff80, /* dst_mask */ |
1012 | FALSE), /* pcrel_offset */ | |
1013 | HOWTO (R_C6000_SBR_L16_H, /* type */ | |
1014 | 1, /* rightshift */ | |
1015 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1016 | 16, /* bitsize */ | |
1017 | FALSE, /* pc_relative */ | |
1018 | 7, /* bitpos */ | |
1019 | complain_overflow_dont,/* complain_on_overflow */ | |
1020 | bfd_elf_generic_reloc, /* special_function */ | |
1021 | "R_C6000_SBR_L16_H", /* name */ | |
41820509 JM |
1022 | TRUE, /* partial_inplace */ |
1023 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
1024 | 0x007fff80, /* dst_mask */ |
1025 | FALSE), /* pcrel_offset */ | |
1026 | HOWTO (R_C6000_SBR_L16_W, /* type */ | |
1027 | 2, /* rightshift */ | |
1028 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1029 | 16, /* bitsize */ | |
1030 | FALSE, /* pc_relative */ | |
1031 | 7, /* bitpos */ | |
1032 | complain_overflow_dont,/* complain_on_overflow */ | |
1033 | bfd_elf_generic_reloc, /* special_function */ | |
1034 | "R_C6000_SBR_L16_W", /* name */ | |
41820509 JM |
1035 | TRUE, /* partial_inplace */ |
1036 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
1037 | 0x007fff80, /* dst_mask */ |
1038 | FALSE), /* pcrel_offset */ | |
41820509 JM |
1039 | EMPTY_HOWTO (R_C6000_SBR_H16_B), |
1040 | EMPTY_HOWTO (R_C6000_SBR_H16_H), | |
1041 | EMPTY_HOWTO (R_C6000_SBR_H16_W), | |
40b36596 JM |
1042 | HOWTO (R_C6000_SBR_GOT_U15_W, /* type */ |
1043 | 2, /* rightshift */ | |
1044 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1045 | 15, /* bitsize */ | |
1046 | FALSE, /* pc_relative */ | |
1047 | 8, /* bitpos */ | |
1048 | complain_overflow_unsigned,/* complain_on_overflow */ | |
1049 | bfd_elf_generic_reloc, /* special_function */ | |
1050 | "R_C6000_SBR_GOT_U15_W",/* name */ | |
41820509 JM |
1051 | TRUE, /* partial_inplace */ |
1052 | 0x007fff00, /* src_mask */ | |
40b36596 JM |
1053 | 0x007fff00, /* dst_mask */ |
1054 | FALSE), /* pcrel_offset */ | |
1055 | HOWTO (R_C6000_SBR_GOT_L16_W, /* type */ | |
1056 | 2, /* rightshift */ | |
1057 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1058 | 16, /* bitsize */ | |
1059 | FALSE, /* pc_relative */ | |
1060 | 7, /* bitpos */ | |
1061 | complain_overflow_dont,/* complain_on_overflow */ | |
1062 | bfd_elf_generic_reloc, /* special_function */ | |
1063 | "R_C6000_SBR_GOT_L16_W",/* name */ | |
41820509 JM |
1064 | TRUE, /* partial_inplace */ |
1065 | 0x007fff80, /* src_mask */ | |
40b36596 JM |
1066 | 0x007fff80, /* dst_mask */ |
1067 | FALSE), /* pcrel_offset */ | |
41820509 | 1068 | EMPTY_HOWTO (R_C6000_SBR_GOT_H16_W), |
40b36596 JM |
1069 | HOWTO (R_C6000_DSBT_INDEX, /* type */ |
1070 | 0, /* rightshift */ | |
1071 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1072 | 15, /* bitsize */ | |
1073 | FALSE, /* pc_relative */ | |
1074 | 8, /* bitpos */ | |
1075 | complain_overflow_unsigned,/* complain_on_overflow */ | |
1076 | bfd_elf_generic_reloc, /* special_function */ | |
1077 | "R_C6000_DSBT_INDEX", /* name */ | |
41820509 | 1078 | TRUE, /* partial_inplace */ |
40b36596 JM |
1079 | 0, /* src_mask */ |
1080 | 0x007fff00, /* dst_mask */ | |
1081 | FALSE), /* pcrel_offset */ | |
1082 | HOWTO (R_C6000_PREL31, /* type */ | |
1083 | 1, /* rightshift */ | |
1084 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1085 | 31, /* bitsize */ | |
44e87ece | 1086 | TRUE, /* pc_relative */ |
40b36596 JM |
1087 | 0, /* bitpos */ |
1088 | complain_overflow_dont,/* complain_on_overflow */ | |
1089 | bfd_elf_generic_reloc, /* special_function */ | |
1090 | "R_C6000_PREL31", /* name */ | |
41820509 | 1091 | TRUE, /* partial_inplace */ |
40b36596 JM |
1092 | 0, /* src_mask */ |
1093 | 0x7fffffff, /* dst_mask */ | |
44e87ece | 1094 | TRUE), /* pcrel_offset */ |
40b36596 JM |
1095 | HOWTO (R_C6000_COPY, /* type */ |
1096 | 0, /* rightshift */ | |
1097 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1098 | 32, /* bitsize */ | |
1099 | FALSE, /* pc_relative */ | |
1100 | 0, /* bitpos */ | |
1101 | complain_overflow_dont,/* complain_on_overflow */ | |
1102 | bfd_elf_generic_reloc, /* special_function */ | |
1103 | "R_C6000_COPY", /* name */ | |
41820509 | 1104 | TRUE, /* partial_inplace */ |
40b36596 JM |
1105 | 0, /* src_mask */ |
1106 | 0xffffffff, /* dst_mask */ | |
1107 | FALSE), /* pcrel_offset */ | |
ac145307 BS |
1108 | HOWTO (R_C6000_JUMP_SLOT, /* type */ |
1109 | 0, /* rightshift */ | |
1110 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1111 | 32, /* bitsize */ | |
1112 | FALSE, /* pc_relative */ | |
1113 | 0, /* bitpos */ | |
1114 | complain_overflow_dont,/* complain_on_overflow */ | |
1115 | bfd_elf_generic_reloc, /* special_function */ | |
1116 | "R_C6000_JUMP_SLOT", /* name */ | |
1117 | FALSE, /* partial_inplace */ | |
1118 | 0, /* src_mask */ | |
1119 | 0xffffffff, /* dst_mask */ | |
1120 | FALSE), /* pcrel_offset */ | |
2fbb87f6 PB |
1121 | HOWTO (R_C6000_EHTYPE, /* type */ |
1122 | 0, /* rightshift */ | |
1123 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1124 | 32, /* bitsize */ | |
1125 | FALSE, /* pc_relative */ | |
1126 | 0, /* bitpos */ | |
1127 | complain_overflow_dont,/* complain_on_overflow */ | |
1128 | bfd_elf_generic_reloc, /* special_function */ | |
1129 | "R_C6000_EHTYPE", /* name */ | |
1130 | FALSE, /* partial_inplace */ | |
1131 | 0, /* src_mask */ | |
1132 | 0xffffffff, /* dst_mask */ | |
1133 | FALSE), /* pcrel_offset */ | |
4a732032 BS |
1134 | EMPTY_HOWTO (R_C6000_PCR_H16), |
1135 | EMPTY_HOWTO (R_C6000_PCR_L16), | |
40b36596 JM |
1136 | EMPTY_HOWTO (31), |
1137 | EMPTY_HOWTO (32), | |
1138 | EMPTY_HOWTO (33), | |
1139 | EMPTY_HOWTO (34), | |
1140 | EMPTY_HOWTO (35), | |
1141 | EMPTY_HOWTO (36), | |
1142 | EMPTY_HOWTO (37), | |
1143 | EMPTY_HOWTO (38), | |
1144 | EMPTY_HOWTO (39), | |
1145 | EMPTY_HOWTO (40), | |
1146 | EMPTY_HOWTO (41), | |
1147 | EMPTY_HOWTO (42), | |
1148 | EMPTY_HOWTO (43), | |
1149 | EMPTY_HOWTO (44), | |
1150 | EMPTY_HOWTO (45), | |
1151 | EMPTY_HOWTO (46), | |
1152 | EMPTY_HOWTO (47), | |
1153 | EMPTY_HOWTO (48), | |
1154 | EMPTY_HOWTO (49), | |
1155 | EMPTY_HOWTO (50), | |
1156 | EMPTY_HOWTO (51), | |
1157 | EMPTY_HOWTO (52), | |
1158 | EMPTY_HOWTO (53), | |
1159 | EMPTY_HOWTO (54), | |
1160 | EMPTY_HOWTO (55), | |
1161 | EMPTY_HOWTO (56), | |
1162 | EMPTY_HOWTO (57), | |
1163 | EMPTY_HOWTO (58), | |
1164 | EMPTY_HOWTO (59), | |
1165 | EMPTY_HOWTO (60), | |
1166 | EMPTY_HOWTO (61), | |
1167 | EMPTY_HOWTO (62), | |
1168 | EMPTY_HOWTO (63), | |
1169 | EMPTY_HOWTO (64), | |
1170 | EMPTY_HOWTO (65), | |
1171 | EMPTY_HOWTO (66), | |
1172 | EMPTY_HOWTO (67), | |
1173 | EMPTY_HOWTO (68), | |
1174 | EMPTY_HOWTO (69), | |
1175 | EMPTY_HOWTO (70), | |
1176 | EMPTY_HOWTO (71), | |
1177 | EMPTY_HOWTO (72), | |
1178 | EMPTY_HOWTO (73), | |
1179 | EMPTY_HOWTO (74), | |
1180 | EMPTY_HOWTO (75), | |
1181 | EMPTY_HOWTO (76), | |
1182 | EMPTY_HOWTO (77), | |
1183 | EMPTY_HOWTO (78), | |
1184 | EMPTY_HOWTO (79), | |
1185 | EMPTY_HOWTO (80), | |
1186 | EMPTY_HOWTO (81), | |
1187 | EMPTY_HOWTO (82), | |
1188 | EMPTY_HOWTO (83), | |
1189 | EMPTY_HOWTO (84), | |
1190 | EMPTY_HOWTO (85), | |
1191 | EMPTY_HOWTO (86), | |
1192 | EMPTY_HOWTO (87), | |
1193 | EMPTY_HOWTO (88), | |
1194 | EMPTY_HOWTO (89), | |
1195 | EMPTY_HOWTO (90), | |
1196 | EMPTY_HOWTO (91), | |
1197 | EMPTY_HOWTO (92), | |
1198 | EMPTY_HOWTO (93), | |
1199 | EMPTY_HOWTO (94), | |
1200 | EMPTY_HOWTO (95), | |
1201 | EMPTY_HOWTO (96), | |
1202 | EMPTY_HOWTO (97), | |
1203 | EMPTY_HOWTO (98), | |
1204 | EMPTY_HOWTO (99), | |
1205 | EMPTY_HOWTO (100), | |
1206 | EMPTY_HOWTO (101), | |
1207 | EMPTY_HOWTO (102), | |
1208 | EMPTY_HOWTO (103), | |
1209 | EMPTY_HOWTO (104), | |
1210 | EMPTY_HOWTO (105), | |
1211 | EMPTY_HOWTO (106), | |
1212 | EMPTY_HOWTO (107), | |
1213 | EMPTY_HOWTO (108), | |
1214 | EMPTY_HOWTO (109), | |
1215 | EMPTY_HOWTO (110), | |
1216 | EMPTY_HOWTO (111), | |
1217 | EMPTY_HOWTO (112), | |
1218 | EMPTY_HOWTO (113), | |
1219 | EMPTY_HOWTO (114), | |
1220 | EMPTY_HOWTO (115), | |
1221 | EMPTY_HOWTO (116), | |
1222 | EMPTY_HOWTO (117), | |
1223 | EMPTY_HOWTO (118), | |
1224 | EMPTY_HOWTO (119), | |
1225 | EMPTY_HOWTO (120), | |
1226 | EMPTY_HOWTO (121), | |
1227 | EMPTY_HOWTO (122), | |
1228 | EMPTY_HOWTO (123), | |
1229 | EMPTY_HOWTO (124), | |
1230 | EMPTY_HOWTO (125), | |
1231 | EMPTY_HOWTO (126), | |
1232 | EMPTY_HOWTO (127), | |
1233 | EMPTY_HOWTO (128), | |
1234 | EMPTY_HOWTO (129), | |
1235 | EMPTY_HOWTO (130), | |
1236 | EMPTY_HOWTO (131), | |
1237 | EMPTY_HOWTO (132), | |
1238 | EMPTY_HOWTO (133), | |
1239 | EMPTY_HOWTO (134), | |
1240 | EMPTY_HOWTO (135), | |
1241 | EMPTY_HOWTO (136), | |
1242 | EMPTY_HOWTO (137), | |
1243 | EMPTY_HOWTO (138), | |
1244 | EMPTY_HOWTO (139), | |
1245 | EMPTY_HOWTO (140), | |
1246 | EMPTY_HOWTO (141), | |
1247 | EMPTY_HOWTO (142), | |
1248 | EMPTY_HOWTO (143), | |
1249 | EMPTY_HOWTO (144), | |
1250 | EMPTY_HOWTO (145), | |
1251 | EMPTY_HOWTO (146), | |
1252 | EMPTY_HOWTO (147), | |
1253 | EMPTY_HOWTO (148), | |
1254 | EMPTY_HOWTO (149), | |
1255 | EMPTY_HOWTO (150), | |
1256 | EMPTY_HOWTO (151), | |
1257 | EMPTY_HOWTO (152), | |
1258 | EMPTY_HOWTO (153), | |
1259 | EMPTY_HOWTO (154), | |
1260 | EMPTY_HOWTO (155), | |
1261 | EMPTY_HOWTO (156), | |
1262 | EMPTY_HOWTO (157), | |
1263 | EMPTY_HOWTO (158), | |
1264 | EMPTY_HOWTO (159), | |
1265 | EMPTY_HOWTO (160), | |
1266 | EMPTY_HOWTO (161), | |
1267 | EMPTY_HOWTO (162), | |
1268 | EMPTY_HOWTO (163), | |
1269 | EMPTY_HOWTO (164), | |
1270 | EMPTY_HOWTO (165), | |
1271 | EMPTY_HOWTO (166), | |
1272 | EMPTY_HOWTO (167), | |
1273 | EMPTY_HOWTO (168), | |
1274 | EMPTY_HOWTO (169), | |
1275 | EMPTY_HOWTO (170), | |
1276 | EMPTY_HOWTO (171), | |
1277 | EMPTY_HOWTO (172), | |
1278 | EMPTY_HOWTO (173), | |
1279 | EMPTY_HOWTO (174), | |
1280 | EMPTY_HOWTO (175), | |
1281 | EMPTY_HOWTO (176), | |
1282 | EMPTY_HOWTO (177), | |
1283 | EMPTY_HOWTO (178), | |
1284 | EMPTY_HOWTO (179), | |
1285 | EMPTY_HOWTO (180), | |
1286 | EMPTY_HOWTO (181), | |
1287 | EMPTY_HOWTO (182), | |
1288 | EMPTY_HOWTO (183), | |
1289 | EMPTY_HOWTO (184), | |
1290 | EMPTY_HOWTO (185), | |
1291 | EMPTY_HOWTO (186), | |
1292 | EMPTY_HOWTO (187), | |
1293 | EMPTY_HOWTO (188), | |
1294 | EMPTY_HOWTO (189), | |
1295 | EMPTY_HOWTO (190), | |
1296 | EMPTY_HOWTO (191), | |
1297 | EMPTY_HOWTO (192), | |
1298 | EMPTY_HOWTO (193), | |
1299 | EMPTY_HOWTO (194), | |
1300 | EMPTY_HOWTO (195), | |
1301 | EMPTY_HOWTO (196), | |
1302 | EMPTY_HOWTO (197), | |
1303 | EMPTY_HOWTO (198), | |
1304 | EMPTY_HOWTO (199), | |
1305 | EMPTY_HOWTO (200), | |
1306 | EMPTY_HOWTO (201), | |
1307 | EMPTY_HOWTO (202), | |
1308 | EMPTY_HOWTO (203), | |
1309 | EMPTY_HOWTO (204), | |
1310 | EMPTY_HOWTO (205), | |
1311 | EMPTY_HOWTO (206), | |
1312 | EMPTY_HOWTO (207), | |
1313 | EMPTY_HOWTO (208), | |
1314 | EMPTY_HOWTO (209), | |
1315 | EMPTY_HOWTO (210), | |
1316 | EMPTY_HOWTO (211), | |
1317 | EMPTY_HOWTO (212), | |
1318 | EMPTY_HOWTO (213), | |
1319 | EMPTY_HOWTO (214), | |
1320 | EMPTY_HOWTO (215), | |
1321 | EMPTY_HOWTO (216), | |
1322 | EMPTY_HOWTO (217), | |
1323 | EMPTY_HOWTO (218), | |
1324 | EMPTY_HOWTO (219), | |
1325 | EMPTY_HOWTO (220), | |
1326 | EMPTY_HOWTO (221), | |
1327 | EMPTY_HOWTO (222), | |
1328 | EMPTY_HOWTO (223), | |
1329 | EMPTY_HOWTO (224), | |
1330 | EMPTY_HOWTO (225), | |
1331 | EMPTY_HOWTO (226), | |
1332 | EMPTY_HOWTO (227), | |
1333 | EMPTY_HOWTO (228), | |
1334 | EMPTY_HOWTO (229), | |
1335 | EMPTY_HOWTO (230), | |
1336 | EMPTY_HOWTO (231), | |
1337 | EMPTY_HOWTO (232), | |
1338 | EMPTY_HOWTO (233), | |
1339 | EMPTY_HOWTO (234), | |
1340 | EMPTY_HOWTO (235), | |
1341 | EMPTY_HOWTO (236), | |
1342 | EMPTY_HOWTO (237), | |
1343 | EMPTY_HOWTO (238), | |
1344 | EMPTY_HOWTO (239), | |
1345 | EMPTY_HOWTO (240), | |
1346 | EMPTY_HOWTO (241), | |
1347 | EMPTY_HOWTO (242), | |
1348 | EMPTY_HOWTO (243), | |
1349 | EMPTY_HOWTO (244), | |
1350 | EMPTY_HOWTO (245), | |
1351 | EMPTY_HOWTO (246), | |
1352 | EMPTY_HOWTO (247), | |
1353 | EMPTY_HOWTO (248), | |
1354 | EMPTY_HOWTO (249), | |
1355 | EMPTY_HOWTO (250), | |
1356 | EMPTY_HOWTO (251), | |
1357 | EMPTY_HOWTO (252), | |
1358 | HOWTO (R_C6000_ALIGN, /* type */ | |
1359 | 0, /* rightshift */ | |
1360 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1361 | 0, /* bitsize */ | |
1362 | FALSE, /* pc_relative */ | |
1363 | 0, /* bitpos */ | |
1364 | complain_overflow_dont,/* complain_on_overflow */ | |
1365 | bfd_elf_generic_reloc, /* special_function */ | |
1366 | "R_C6000_ALIGN", /* name */ | |
41820509 | 1367 | TRUE, /* partial_inplace */ |
40b36596 JM |
1368 | 0, /* src_mask */ |
1369 | 0, /* dst_mask */ | |
1370 | FALSE), /* pcrel_offset */ | |
1371 | HOWTO (R_C6000_FPHEAD, /* type */ | |
1372 | 0, /* rightshift */ | |
1373 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1374 | 0, /* bitsize */ | |
1375 | FALSE, /* pc_relative */ | |
1376 | 0, /* bitpos */ | |
1377 | complain_overflow_dont,/* complain_on_overflow */ | |
1378 | bfd_elf_generic_reloc, /* special_function */ | |
1379 | "R_C6000_FPHEAD", /* name */ | |
41820509 | 1380 | TRUE, /* partial_inplace */ |
40b36596 JM |
1381 | 0, /* src_mask */ |
1382 | 0, /* dst_mask */ | |
1383 | FALSE), /* pcrel_offset */ | |
1384 | HOWTO (R_C6000_NOCMP, /* type */ | |
1385 | 0, /* rightshift */ | |
1386 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
1387 | 0, /* bitsize */ | |
1388 | FALSE, /* pc_relative */ | |
1389 | 0, /* bitpos */ | |
1390 | complain_overflow_dont,/* complain_on_overflow */ | |
1391 | bfd_elf_generic_reloc, /* special_function */ | |
1392 | "R_C6000_NOCMP", /* name */ | |
41820509 | 1393 | TRUE, /* partial_inplace */ |
40b36596 JM |
1394 | 0, /* src_mask */ |
1395 | 0, /* dst_mask */ | |
1396 | FALSE) /* pcrel_offset */ | |
1397 | }; | |
1398 | ||
1399 | /* Map BFD relocations to ELF relocations. */ | |
1400 | ||
1401 | typedef struct | |
1402 | { | |
1403 | bfd_reloc_code_real_type bfd_reloc_val; | |
1404 | enum elf_tic6x_reloc_type elf_reloc_val; | |
1405 | } tic6x_reloc_map; | |
1406 | ||
1407 | static const tic6x_reloc_map elf32_tic6x_reloc_map[] = | |
1408 | { | |
1409 | { BFD_RELOC_NONE, R_C6000_NONE }, | |
1410 | { BFD_RELOC_32, R_C6000_ABS32 }, | |
1411 | { BFD_RELOC_16, R_C6000_ABS16 }, | |
1412 | { BFD_RELOC_8, R_C6000_ABS8 }, | |
1413 | { BFD_RELOC_C6000_PCR_S21, R_C6000_PCR_S21 }, | |
1414 | { BFD_RELOC_C6000_PCR_S12, R_C6000_PCR_S12 }, | |
1415 | { BFD_RELOC_C6000_PCR_S10, R_C6000_PCR_S10 }, | |
1416 | { BFD_RELOC_C6000_PCR_S7, R_C6000_PCR_S7 }, | |
1417 | { BFD_RELOC_C6000_ABS_S16, R_C6000_ABS_S16 }, | |
1418 | { BFD_RELOC_C6000_ABS_L16, R_C6000_ABS_L16 }, | |
1419 | { BFD_RELOC_C6000_ABS_H16, R_C6000_ABS_H16 }, | |
1420 | { BFD_RELOC_C6000_SBR_U15_B, R_C6000_SBR_U15_B }, | |
1421 | { BFD_RELOC_C6000_SBR_U15_H, R_C6000_SBR_U15_H }, | |
1422 | { BFD_RELOC_C6000_SBR_U15_W, R_C6000_SBR_U15_W }, | |
1423 | { BFD_RELOC_C6000_SBR_S16, R_C6000_SBR_S16 }, | |
1424 | { BFD_RELOC_C6000_SBR_L16_B, R_C6000_SBR_L16_B }, | |
1425 | { BFD_RELOC_C6000_SBR_L16_H, R_C6000_SBR_L16_H }, | |
1426 | { BFD_RELOC_C6000_SBR_L16_W, R_C6000_SBR_L16_W }, | |
1427 | { BFD_RELOC_C6000_SBR_H16_B, R_C6000_SBR_H16_B }, | |
1428 | { BFD_RELOC_C6000_SBR_H16_H, R_C6000_SBR_H16_H }, | |
1429 | { BFD_RELOC_C6000_SBR_H16_W, R_C6000_SBR_H16_W }, | |
1430 | { BFD_RELOC_C6000_SBR_GOT_U15_W, R_C6000_SBR_GOT_U15_W }, | |
1431 | { BFD_RELOC_C6000_SBR_GOT_L16_W, R_C6000_SBR_GOT_L16_W }, | |
1432 | { BFD_RELOC_C6000_SBR_GOT_H16_W, R_C6000_SBR_GOT_H16_W }, | |
1433 | { BFD_RELOC_C6000_DSBT_INDEX, R_C6000_DSBT_INDEX }, | |
1434 | { BFD_RELOC_C6000_PREL31, R_C6000_PREL31 }, | |
1435 | { BFD_RELOC_C6000_COPY, R_C6000_COPY }, | |
ac145307 BS |
1436 | { BFD_RELOC_C6000_JUMP_SLOT, R_C6000_JUMP_SLOT }, |
1437 | { BFD_RELOC_C6000_EHTYPE, R_C6000_EHTYPE }, | |
1438 | { BFD_RELOC_C6000_PCR_H16, R_C6000_PCR_H16 }, | |
1439 | { BFD_RELOC_C6000_PCR_L16, R_C6000_PCR_L16 }, | |
40b36596 JM |
1440 | { BFD_RELOC_C6000_ALIGN, R_C6000_ALIGN }, |
1441 | { BFD_RELOC_C6000_FPHEAD, R_C6000_FPHEAD }, | |
1442 | { BFD_RELOC_C6000_NOCMP, R_C6000_NOCMP } | |
1443 | }; | |
1444 | ||
1445 | static reloc_howto_type * | |
41820509 | 1446 | elf32_tic6x_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) |
40b36596 JM |
1447 | { |
1448 | unsigned int i; | |
1449 | ||
1450 | for (i = 0; i < ARRAY_SIZE (elf32_tic6x_reloc_map); i++) | |
1451 | if (elf32_tic6x_reloc_map[i].bfd_reloc_val == code) | |
41820509 JM |
1452 | { |
1453 | enum elf_tic6x_reloc_type elf_reloc_val; | |
1454 | reloc_howto_type *howto; | |
1455 | ||
1456 | elf_reloc_val = elf32_tic6x_reloc_map[i].elf_reloc_val; | |
1457 | if (elf32_tic6x_tdata (abfd)->use_rela_p) | |
1458 | howto = &elf32_tic6x_howto_table[elf_reloc_val]; | |
1459 | else | |
1460 | howto = &elf32_tic6x_howto_table_rel[elf_reloc_val]; | |
1461 | ||
1462 | /* Some relocations are RELA-only; do not return them for | |
1463 | REL. */ | |
1464 | if (howto->name == NULL) | |
1465 | howto = NULL; | |
1466 | ||
1467 | return howto; | |
1468 | } | |
40b36596 JM |
1469 | |
1470 | return NULL; | |
1471 | } | |
1472 | ||
1473 | static reloc_howto_type * | |
41820509 | 1474 | elf32_tic6x_reloc_name_lookup (bfd *abfd, const char *r_name) |
40b36596 | 1475 | { |
41820509 JM |
1476 | if (elf32_tic6x_tdata (abfd)->use_rela_p) |
1477 | { | |
1478 | unsigned int i; | |
1479 | ||
1480 | for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table); i++) | |
1481 | if (elf32_tic6x_howto_table[i].name != NULL | |
1482 | && strcasecmp (elf32_tic6x_howto_table[i].name, r_name) == 0) | |
1483 | return &elf32_tic6x_howto_table[i]; | |
1484 | } | |
1485 | else | |
1486 | { | |
1487 | unsigned int i; | |
40b36596 | 1488 | |
41820509 JM |
1489 | for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table_rel); i++) |
1490 | if (elf32_tic6x_howto_table_rel[i].name != NULL | |
1491 | && strcasecmp (elf32_tic6x_howto_table_rel[i].name, r_name) == 0) | |
1492 | return &elf32_tic6x_howto_table_rel[i]; | |
1493 | } | |
40b36596 JM |
1494 | |
1495 | return NULL; | |
1496 | } | |
1497 | ||
1498 | static void | |
1499 | elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, | |
1500 | Elf_Internal_Rela *elf_reloc) | |
1501 | { | |
1502 | unsigned int r_type; | |
1503 | ||
1504 | r_type = ELF32_R_TYPE (elf_reloc->r_info); | |
1505 | if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table)) | |
1506 | bfd_reloc->howto = NULL; | |
1507 | else | |
1508 | bfd_reloc->howto = &elf32_tic6x_howto_table[r_type]; | |
1509 | } | |
1510 | ||
41820509 JM |
1511 | static void |
1512 | elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc, | |
1513 | Elf_Internal_Rela *elf_reloc) | |
1514 | { | |
1515 | unsigned int r_type; | |
1516 | ||
1517 | r_type = ELF32_R_TYPE (elf_reloc->r_info); | |
1518 | if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table_rel)) | |
1519 | bfd_reloc->howto = NULL; | |
1520 | else | |
1521 | bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type]; | |
1522 | } | |
1523 | ||
1524 | void | |
1525 | elf32_tic6x_set_use_rela_p (bfd *abfd, bfd_boolean use_rela_p) | |
1526 | { | |
1527 | elf32_tic6x_tdata (abfd)->use_rela_p = use_rela_p; | |
1528 | } | |
1529 | ||
ac145307 BS |
1530 | /* Create an entry in a C6X ELF linker hash table. */ |
1531 | ||
1532 | static struct bfd_hash_entry * | |
1533 | elf32_tic6x_link_hash_newfunc (struct bfd_hash_entry *entry, | |
1534 | struct bfd_hash_table *table, | |
1535 | const char *string) | |
1536 | { | |
1537 | /* Allocate the structure if it has not already been allocated by a | |
1538 | subclass. */ | |
1539 | if (entry == NULL) | |
1540 | { | |
1541 | entry = bfd_hash_allocate (table, | |
1542 | sizeof (struct elf32_tic6x_link_hash_entry)); | |
1543 | if (entry == NULL) | |
1544 | return entry; | |
1545 | } | |
1546 | ||
1547 | /* Call the allocation method of the superclass. */ | |
1548 | entry = _bfd_elf_link_hash_newfunc (entry, table, string); | |
1549 | if (entry != NULL) | |
1550 | { | |
1551 | struct elf32_tic6x_link_hash_entry *eh; | |
1552 | ||
1553 | eh = (struct elf32_tic6x_link_hash_entry *) entry; | |
1554 | eh->dyn_relocs = NULL; | |
1555 | } | |
1556 | ||
1557 | return entry; | |
1558 | } | |
1559 | ||
1560 | /* Create a C6X ELF linker hash table. */ | |
1561 | ||
1562 | static struct bfd_link_hash_table * | |
1563 | elf32_tic6x_link_hash_table_create (bfd *abfd) | |
1564 | { | |
1565 | struct elf32_tic6x_link_hash_table *ret; | |
1566 | bfd_size_type amt = sizeof (struct elf32_tic6x_link_hash_table); | |
1567 | ||
7bf52ea2 | 1568 | ret = bfd_zmalloc (amt); |
ac145307 BS |
1569 | if (ret == NULL) |
1570 | return NULL; | |
1571 | ||
1572 | if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, | |
1573 | elf32_tic6x_link_hash_newfunc, | |
1574 | sizeof (struct elf32_tic6x_link_hash_entry), | |
1575 | TIC6X_ELF_DATA)) | |
1576 | { | |
1577 | free (ret); | |
1578 | return NULL; | |
1579 | } | |
1580 | ||
ac145307 BS |
1581 | ret->obfd = abfd; |
1582 | ret->elf.is_relocatable_executable = 1; | |
1583 | ||
1584 | return &ret->elf.root; | |
1585 | } | |
1586 | ||
c6a8f6e0 BS |
1587 | static bfd_boolean |
1588 | elf32_tic6x_final_link (bfd *abfd, struct bfd_link_info *info) | |
1589 | { | |
0e1862bb | 1590 | if (bfd_link_pic (info)) |
c6a8f6e0 BS |
1591 | { |
1592 | obj_attribute *out_attr; | |
1593 | out_attr = elf_known_obj_attributes_proc (abfd); | |
1594 | if (out_attr[Tag_ABI_PIC].i == 0) | |
1595 | { | |
1596 | _bfd_error_handler (_("warning: generating a shared library " | |
1597 | "containing non-PIC code")); | |
1598 | } | |
1599 | if (out_attr[Tag_ABI_PID].i == 0) | |
1600 | { | |
1601 | _bfd_error_handler (_("warning: generating a shared library " | |
1602 | "containing non-PID code")); | |
1603 | } | |
1604 | } | |
1605 | /* Invoke the regular ELF backend linker to do all the work. */ | |
1606 | if (!bfd_elf_final_link (abfd, info)) | |
1607 | return FALSE; | |
1608 | ||
1609 | return TRUE; | |
1610 | } | |
1611 | ||
ac145307 BS |
1612 | /* Called to pass PARAMS to the backend. We store them in the hash table |
1613 | associated with INFO. */ | |
1614 | ||
1615 | void | |
1616 | elf32_tic6x_setup (struct bfd_link_info *info, | |
1617 | struct elf32_tic6x_params *params) | |
1618 | { | |
1619 | struct elf32_tic6x_link_hash_table *htab = elf32_tic6x_hash_table (info); | |
1620 | htab->params = *params; | |
1621 | } | |
1622 | ||
1623 | /* Determine if we're dealing with a DSBT object. */ | |
1624 | ||
1625 | static bfd_boolean | |
1626 | elf32_tic6x_using_dsbt (bfd *abfd) | |
1627 | { | |
1628 | return bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, | |
1629 | Tag_ABI_DSBT); | |
1630 | } | |
1631 | ||
1632 | /* Create .plt, .rela.plt, .got, .got.plt, .rela.got and .dsbt | |
1633 | sections in DYNOBJ, and set up shortcuts to them in our hash | |
1634 | table. */ | |
1635 | ||
1636 | static bfd_boolean | |
1637 | elf32_tic6x_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) | |
1638 | { | |
1639 | struct elf32_tic6x_link_hash_table *htab; | |
1640 | flagword flags; | |
1641 | ||
1642 | htab = elf32_tic6x_hash_table (info); | |
1643 | if (htab == NULL) | |
1644 | return FALSE; | |
1645 | ||
1646 | if (!_bfd_elf_create_dynamic_sections (dynobj, info)) | |
1647 | return FALSE; | |
1648 | ||
1649 | /* Create .dsbt */ | |
1650 | flags = (SEC_ALLOC | SEC_LOAD | |
1651 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); | |
1652 | htab->dsbt = bfd_make_section_anyway_with_flags (dynobj, ".dsbt", | |
1653 | flags); | |
1654 | if (htab->dsbt == NULL | |
1655 | || ! bfd_set_section_alignment (dynobj, htab->dsbt, 2) | |
1656 | || ! bfd_set_section_alignment (dynobj, htab->elf.splt, 5)) | |
1657 | return FALSE; | |
1658 | ||
ac145307 BS |
1659 | return TRUE; |
1660 | } | |
1661 | ||
41820509 JM |
1662 | static bfd_boolean |
1663 | elf32_tic6x_mkobject (bfd *abfd) | |
1664 | { | |
1665 | bfd_boolean ret; | |
1666 | ||
1667 | ret = bfd_elf_allocate_object (abfd, sizeof (struct elf32_tic6x_obj_tdata), | |
1668 | TIC6X_ELF_DATA); | |
1669 | if (ret) | |
1670 | elf32_tic6x_set_use_rela_p (abfd, TRUE); | |
1671 | return ret; | |
1672 | } | |
1673 | ||
ac145307 BS |
1674 | /* Install relocation RELA into section SRELA, incrementing its |
1675 | reloc_count. */ | |
1676 | ||
1677 | static void | |
1678 | elf32_tic6x_install_rela (bfd *output_bfd, asection *srela, | |
1679 | Elf_Internal_Rela *rela) | |
1680 | { | |
1681 | bfd_byte *loc; | |
1682 | bfd_vma off = srela->reloc_count++ * sizeof (Elf32_External_Rela); | |
1683 | loc = srela->contents + off; | |
1684 | BFD_ASSERT (off < srela->size); | |
1685 | bfd_elf32_swap_reloca_out (output_bfd, rela, loc); | |
1686 | } | |
1687 | ||
1688 | /* Create a dynamic reloc against the GOT at offset OFFSET. The contents | |
1689 | of the GOT at this offset have been initialized with the relocation. */ | |
1690 | ||
1691 | static void | |
1692 | elf32_tic6x_make_got_dynreloc (bfd *output_bfd, | |
1693 | struct elf32_tic6x_link_hash_table *htab, | |
1694 | asection *sym_sec, bfd_vma offset) | |
1695 | { | |
1696 | asection *sgot = htab->elf.sgot; | |
1697 | Elf_Internal_Rela outrel; | |
1698 | int dynindx; | |
1699 | ||
1700 | outrel.r_offset = sgot->output_section->vma + sgot->output_offset + offset; | |
1701 | outrel.r_addend = bfd_get_32 (output_bfd, sgot->contents + offset); | |
1702 | if (sym_sec && sym_sec->output_section | |
1703 | && ! bfd_is_abs_section (sym_sec->output_section) | |
1704 | && ! bfd_is_und_section (sym_sec->output_section)) | |
1705 | { | |
1706 | dynindx = elf_section_data (sym_sec->output_section)->dynindx; | |
1707 | outrel.r_addend -= sym_sec->output_section->vma; | |
1708 | } | |
1709 | else | |
1710 | { | |
1711 | dynindx = 0; | |
1712 | } | |
1713 | outrel.r_info = ELF32_R_INFO (dynindx, R_C6000_ABS32); | |
1714 | elf32_tic6x_install_rela (output_bfd, htab->elf.srelgot, &outrel); | |
1715 | } | |
1716 | ||
1717 | /* Finish up dynamic symbol handling. We set the contents of various | |
1718 | dynamic sections here. */ | |
1719 | ||
1720 | static bfd_boolean | |
1721 | elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd, | |
1722 | struct bfd_link_info *info, | |
1723 | struct elf_link_hash_entry *h, | |
1724 | Elf_Internal_Sym * sym) | |
1725 | { | |
ac145307 BS |
1726 | struct elf32_tic6x_link_hash_table *htab; |
1727 | ||
1728 | htab = elf32_tic6x_hash_table (info); | |
ac145307 BS |
1729 | |
1730 | if (h->plt.offset != (bfd_vma) -1) | |
1731 | { | |
1732 | bfd_vma plt_index; | |
1733 | bfd_vma got_section_offset, got_dp_offset, rela_offset; | |
1734 | Elf_Internal_Rela rela; | |
1735 | bfd_byte *loc; | |
1736 | asection *plt, *gotplt, *relplt; | |
1737 | const struct elf_backend_data *bed; | |
1738 | ||
1739 | bed = get_elf_backend_data (output_bfd); | |
1740 | ||
1741 | BFD_ASSERT (htab->elf.splt != NULL); | |
1742 | plt = htab->elf.splt; | |
1743 | gotplt = htab->elf.sgotplt; | |
1744 | relplt = htab->elf.srelplt; | |
1745 | ||
1746 | /* This symbol has an entry in the procedure linkage table. Set | |
1747 | it up. */ | |
1748 | ||
1749 | if ((h->dynindx == -1 | |
0e1862bb | 1750 | && !((h->forced_local || bfd_link_executable (info)) |
ac145307 BS |
1751 | && h->def_regular |
1752 | && h->type == STT_GNU_IFUNC)) | |
1753 | || plt == NULL | |
1754 | || gotplt == NULL | |
1755 | || relplt == NULL) | |
1756 | abort (); | |
1757 | ||
1758 | /* Get the index in the procedure linkage table which | |
1759 | corresponds to this symbol. This is the index of this symbol | |
1760 | in all the symbols for which we are making plt entries. The | |
1761 | first entry in the procedure linkage table is reserved. | |
1762 | ||
1763 | Get the offset into the .got table of the entry that | |
1764 | corresponds to this function. Each .got entry is 4 bytes. | |
1765 | The first three are reserved. | |
68ffbac6 | 1766 | |
ac145307 BS |
1767 | For static executables, we don't reserve anything. */ |
1768 | ||
1769 | plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; | |
1770 | got_section_offset = plt_index + bed->got_header_size / 4; | |
1771 | got_dp_offset = got_section_offset + htab->params.dsbt_size; | |
1772 | rela_offset = plt_index * sizeof (Elf32_External_Rela); | |
1773 | ||
1774 | got_section_offset *= 4; | |
1775 | ||
1776 | /* Fill in the entry in the procedure linkage table. */ | |
1777 | ||
1778 | /* ldw .d2t2 *+B14($GOT(f)), b2 */ | |
1779 | bfd_put_32 (output_bfd, got_dp_offset << 8 | 0x0100006e, | |
1780 | plt->contents + h->plt.offset); | |
1781 | /* mvk .s2 low(rela_offset), b0 */ | |
1782 | bfd_put_32 (output_bfd, (rela_offset & 0xffff) << 7 | 0x0000002a, | |
1783 | plt->contents + h->plt.offset + 4); | |
1784 | /* mvkh .s2 high(rela_offset), b0 */ | |
1785 | bfd_put_32 (output_bfd, ((rela_offset >> 16) & 0xffff) << 7 | 0x0000006a, | |
1786 | plt->contents + h->plt.offset + 8); | |
1787 | /* nop 2 */ | |
1788 | bfd_put_32 (output_bfd, 0x00002000, | |
1789 | plt->contents + h->plt.offset + 12); | |
1790 | /* b .s2 b2 */ | |
1791 | bfd_put_32 (output_bfd, 0x00080362, | |
1792 | plt->contents + h->plt.offset + 16); | |
1793 | /* nop 5 */ | |
1794 | bfd_put_32 (output_bfd, 0x00008000, | |
1795 | plt->contents + h->plt.offset + 20); | |
1796 | ||
1797 | /* Fill in the entry in the global offset table. */ | |
1798 | bfd_put_32 (output_bfd, | |
1799 | (plt->output_section->vma + plt->output_offset), | |
1800 | gotplt->contents + got_section_offset); | |
1801 | ||
1802 | /* Fill in the entry in the .rel.plt section. */ | |
1803 | rela.r_offset = (gotplt->output_section->vma | |
1804 | + gotplt->output_offset | |
1805 | + got_section_offset); | |
1806 | rela.r_info = ELF32_R_INFO (h->dynindx, R_C6000_JUMP_SLOT); | |
1807 | rela.r_addend = 0; | |
1808 | loc = relplt->contents + rela_offset; | |
1809 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); | |
1810 | ||
1811 | if (!h->def_regular) | |
1812 | { | |
1813 | /* Mark the symbol as undefined, rather than as defined in | |
1814 | the .plt section. */ | |
1815 | sym->st_shndx = SHN_UNDEF; | |
1816 | sym->st_value = 0; | |
1817 | } | |
1818 | } | |
1819 | ||
1820 | if (h->got.offset != (bfd_vma) -1) | |
1821 | { | |
1822 | asection *sgot; | |
1823 | asection *srela; | |
1824 | ||
1825 | /* This symbol has an entry in the global offset table. | |
07d6d2b8 | 1826 | Set it up. */ |
ac145307 | 1827 | |
ce558b89 AM |
1828 | sgot = htab->elf.sgot; |
1829 | srela = htab->elf.srelgot; | |
ac145307 BS |
1830 | BFD_ASSERT (sgot != NULL && srela != NULL); |
1831 | ||
1832 | /* If this is a -Bsymbolic link, and the symbol is defined | |
07d6d2b8 AM |
1833 | locally, we just want to emit a RELATIVE reloc. Likewise if |
1834 | the symbol was forced to be local because of a version file. | |
1835 | The entry in the global offset table will already have been | |
1836 | initialized in the relocate_section function. */ | |
0e1862bb | 1837 | if (bfd_link_pic (info) |
a496fbc8 | 1838 | && (SYMBOLIC_BIND (info, h) |
ac145307 BS |
1839 | || h->dynindx == -1 || h->forced_local) && h->def_regular) |
1840 | { | |
1841 | asection *s = h->root.u.def.section; | |
1842 | elf32_tic6x_make_got_dynreloc (output_bfd, htab, s, | |
1843 | h->got.offset & ~(bfd_vma) 1); | |
1844 | } | |
1845 | else | |
1846 | { | |
1847 | Elf_Internal_Rela outrel; | |
1848 | bfd_put_32 (output_bfd, (bfd_vma) 0, | |
1849 | sgot->contents + (h->got.offset & ~(bfd_vma) 1)); | |
1850 | outrel.r_offset = (sgot->output_section->vma | |
1851 | + sgot->output_offset | |
1852 | + (h->got.offset & ~(bfd_vma) 1)); | |
1853 | outrel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_ABS32); | |
1854 | outrel.r_addend = 0; | |
1855 | ||
1856 | elf32_tic6x_install_rela (output_bfd, srela, &outrel); | |
1857 | } | |
1858 | } | |
1859 | ||
1860 | if (h->needs_copy) | |
1861 | { | |
1862 | Elf_Internal_Rela rel; | |
5474d94f | 1863 | asection *s; |
ac145307 BS |
1864 | |
1865 | /* This symbol needs a copy reloc. Set it up. */ | |
1866 | ||
1867 | if (h->dynindx == -1 | |
1868 | || (h->root.type != bfd_link_hash_defined | |
1869 | && h->root.type != bfd_link_hash_defweak) | |
5474d94f AM |
1870 | || htab->elf.srelbss == NULL |
1871 | || htab->elf.sreldynrelro == NULL) | |
ac145307 BS |
1872 | abort (); |
1873 | ||
1874 | rel.r_offset = (h->root.u.def.value | |
1875 | + h->root.u.def.section->output_section->vma | |
1876 | + h->root.u.def.section->output_offset); | |
1877 | rel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_COPY); | |
1878 | rel.r_addend = 0; | |
afbf7e8e | 1879 | if (h->root.u.def.section == htab->elf.sdynrelro) |
5474d94f AM |
1880 | s = htab->elf.sreldynrelro; |
1881 | else | |
1882 | s = htab->elf.srelbss; | |
ac145307 | 1883 | |
5474d94f | 1884 | elf32_tic6x_install_rela (output_bfd, s, &rel); |
ac145307 BS |
1885 | } |
1886 | ||
1887 | /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ | |
9637f6ef | 1888 | if (h == elf_hash_table (info)->hdynamic |
ac145307 BS |
1889 | || h == elf_hash_table (info)->hgot) |
1890 | sym->st_shndx = SHN_ABS; | |
1891 | ||
1892 | return TRUE; | |
1893 | } | |
1894 | ||
9cf0e282 PB |
1895 | /* Unwinding tables are not referenced directly. This pass marks them as |
1896 | required if the corresponding code section is marked. */ | |
1897 | ||
1898 | static bfd_boolean | |
1899 | elf32_tic6x_gc_mark_extra_sections (struct bfd_link_info *info, | |
1900 | elf_gc_mark_hook_fn gc_mark_hook) | |
1901 | { | |
1902 | bfd *sub; | |
1903 | Elf_Internal_Shdr **elf_shdrp; | |
1904 | bfd_boolean again; | |
1905 | ||
7f6ab9f8 AM |
1906 | _bfd_elf_gc_mark_extra_sections (info, gc_mark_hook); |
1907 | ||
9cf0e282 PB |
1908 | /* Marking EH data may cause additional code sections to be marked, |
1909 | requiring multiple passes. */ | |
1910 | again = TRUE; | |
1911 | while (again) | |
1912 | { | |
1913 | again = FALSE; | |
c72f2fb2 | 1914 | for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
9cf0e282 PB |
1915 | { |
1916 | asection *o; | |
1917 | ||
1918 | if (! is_tic6x_elf (sub)) | |
1919 | continue; | |
1920 | ||
1921 | elf_shdrp = elf_elfsections (sub); | |
1922 | for (o = sub->sections; o != NULL; o = o->next) | |
1923 | { | |
1924 | Elf_Internal_Shdr *hdr; | |
1925 | ||
1926 | hdr = &elf_section_data (o)->this_hdr; | |
1927 | if (hdr->sh_type == SHT_C6000_UNWIND | |
1928 | && hdr->sh_link | |
1929 | && hdr->sh_link < elf_numsections (sub) | |
1930 | && !o->gc_mark | |
1931 | && elf_shdrp[hdr->sh_link]->bfd_section->gc_mark) | |
1932 | { | |
1933 | again = TRUE; | |
1934 | if (!_bfd_elf_gc_mark (info, o, gc_mark_hook)) | |
1935 | return FALSE; | |
1936 | } | |
1937 | } | |
1938 | } | |
1939 | } | |
1940 | ||
1941 | return TRUE; | |
1942 | } | |
1943 | ||
1bce6bd8 PB |
1944 | /* Return TRUE if this is an unwinding table index. */ |
1945 | ||
1946 | static bfd_boolean | |
1947 | is_tic6x_elf_unwind_section_name (const char *name) | |
1948 | { | |
1949 | return (CONST_STRNEQ (name, ELF_STRING_C6000_unwind) | |
1950 | || CONST_STRNEQ (name, ELF_STRING_C6000_unwind_once)); | |
1951 | } | |
1952 | ||
1953 | ||
1954 | /* Set the type and flags for an unwinding index table. We do this by | |
1955 | the section name, which is a hack, but ought to work. */ | |
1956 | ||
1957 | static bfd_boolean | |
1958 | elf32_tic6x_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, | |
1959 | Elf_Internal_Shdr *hdr, asection *sec) | |
1960 | { | |
1961 | const char * name; | |
1962 | ||
1963 | name = bfd_get_section_name (abfd, sec); | |
1964 | ||
1965 | if (is_tic6x_elf_unwind_section_name (name)) | |
1966 | { | |
1967 | hdr->sh_type = SHT_C6000_UNWIND; | |
1968 | hdr->sh_flags |= SHF_LINK_ORDER; | |
1969 | } | |
1970 | ||
1971 | return TRUE; | |
1972 | } | |
1973 | ||
63c1f59d AM |
1974 | /* Find dynamic relocs for H that apply to read-only sections. */ |
1975 | ||
1976 | static asection * | |
1977 | readonly_dynrelocs (struct elf_link_hash_entry *h) | |
1978 | { | |
1979 | struct elf_dyn_relocs *p; | |
1980 | struct elf32_tic6x_link_hash_entry *eh | |
1981 | = (struct elf32_tic6x_link_hash_entry *) h; | |
1982 | ||
1983 | for (p = eh->dyn_relocs; p != NULL; p = p->next) | |
1984 | { | |
1985 | asection *s = p->sec->output_section; | |
1986 | ||
1987 | if (s != NULL && (s->flags & SEC_READONLY) != 0) | |
1988 | return p->sec; | |
1989 | } | |
1990 | return NULL; | |
1991 | } | |
1992 | ||
ac145307 BS |
1993 | /* Adjust a symbol defined by a dynamic object and referenced by a |
1994 | regular object. The current definition is in some section of the | |
1995 | dynamic object, but we're not including those sections. We have to | |
1996 | change the definition to something the rest of the link can | |
1997 | understand. */ | |
1998 | ||
1999 | static bfd_boolean | |
2000 | elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info, | |
2001 | struct elf_link_hash_entry *h) | |
2002 | { | |
2003 | struct elf32_tic6x_link_hash_table *htab; | |
2004 | bfd *dynobj; | |
5474d94f | 2005 | asection *s, *srel; |
ac145307 BS |
2006 | |
2007 | dynobj = elf_hash_table (info)->dynobj; | |
2008 | ||
2009 | /* Make sure we know what is going on here. */ | |
2010 | BFD_ASSERT (dynobj != NULL | |
2011 | && (h->needs_plt | |
60d67dc8 | 2012 | || h->is_weakalias |
ac145307 BS |
2013 | || (h->def_dynamic && h->ref_regular && !h->def_regular))); |
2014 | ||
2015 | /* If this is a function, put it in the procedure linkage table. We | |
2016 | will fill in the contents of the procedure linkage table later, | |
2017 | when we know the address of the .got section. */ | |
2018 | if (h->type == STT_FUNC | |
2019 | || h->needs_plt) | |
2020 | { | |
2021 | if (h->plt.refcount <= 0 | |
2022 | || SYMBOL_CALLS_LOCAL (info, h) | |
2023 | || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT | |
2024 | && h->root.type == bfd_link_hash_undefweak)) | |
2025 | { | |
2026 | /* This case can occur if we saw a PLT32 reloc in an input | |
2027 | file, but the symbol was never referred to by a dynamic | |
2028 | object, or if all references were garbage collected. In | |
2029 | such a case, we don't actually need to build a procedure | |
2030 | linkage table, and we can just do a PC32 reloc instead. */ | |
2031 | h->plt.offset = (bfd_vma) -1; | |
2032 | h->needs_plt = 0; | |
2033 | } | |
2034 | ||
2035 | return TRUE; | |
2036 | } | |
2037 | ||
2038 | /* If this is a weak symbol, and there is a real definition, the | |
2039 | processor independent code will have arranged for us to see the | |
2040 | real definition first, and we can just use the same value. */ | |
60d67dc8 | 2041 | if (h->is_weakalias) |
ac145307 | 2042 | { |
60d67dc8 AM |
2043 | struct elf_link_hash_entry *def = weakdef (h); |
2044 | BFD_ASSERT (def->root.type == bfd_link_hash_defined); | |
2045 | h->root.u.def.section = def->root.u.def.section; | |
2046 | h->root.u.def.value = def->root.u.def.value; | |
2047 | h->non_got_ref = def->non_got_ref; | |
ac145307 BS |
2048 | return TRUE; |
2049 | } | |
2050 | ||
2051 | /* This is a reference to a symbol defined by a dynamic object which | |
2052 | is not a function. */ | |
2053 | ||
2054 | /* If we are creating a shared library, we must presume that the | |
2055 | only references to the symbol are via the global offset table. | |
2056 | For such cases we need not do anything here; the relocations will | |
2057 | be handled correctly by relocate_section. */ | |
0e1862bb | 2058 | if (bfd_link_pic (info)) |
ac145307 BS |
2059 | return TRUE; |
2060 | ||
2061 | /* If there are no references to this symbol that do not use the | |
2062 | GOT, we don't need to generate a copy reloc. */ | |
2063 | if (!h->non_got_ref) | |
2064 | return TRUE; | |
2065 | ||
2066 | /* If -z nocopyreloc was given, we won't generate them either. */ | |
2067 | if (info->nocopyreloc) | |
2068 | { | |
2069 | h->non_got_ref = 0; | |
2070 | return TRUE; | |
2071 | } | |
2072 | ||
2073 | htab = elf32_tic6x_hash_table (info); | |
2074 | if (htab == NULL) | |
2075 | return FALSE; | |
2076 | ||
ac145307 BS |
2077 | /* We must allocate the symbol in our .dynbss section, which will |
2078 | become part of the .bss section of the executable. There will be | |
2079 | an entry for this symbol in the .dynsym section. The dynamic | |
2080 | object will contain position independent code, so all references | |
2081 | from the dynamic object to this symbol will go through the global | |
2082 | offset table. The dynamic linker will use the .dynsym entry to | |
2083 | determine the address it must put in the global offset table, so | |
2084 | both the dynamic object and the regular object will refer to the | |
2085 | same memory location for the variable. */ | |
2086 | ||
2087 | /* We must generate a R_C6000_COPY reloc to tell the dynamic linker to | |
2088 | copy the initial value out of the dynamic object and into the | |
2089 | runtime process image. */ | |
5474d94f AM |
2090 | if ((h->root.u.def.section->flags & SEC_READONLY) != 0) |
2091 | { | |
2092 | s = htab->elf.sdynrelro; | |
2093 | srel = htab->elf.sreldynrelro; | |
2094 | } | |
2095 | else | |
2096 | { | |
2097 | s = htab->elf.sdynbss; | |
2098 | srel = htab->elf.srelbss; | |
2099 | } | |
1d7e9d18 | 2100 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) |
ac145307 | 2101 | { |
5474d94f | 2102 | srel->size += sizeof (Elf32_External_Rela); |
ac145307 BS |
2103 | h->needs_copy = 1; |
2104 | } | |
2105 | ||
6cabe1ea | 2106 | return _bfd_elf_adjust_dynamic_copy (info, h, s); |
ac145307 BS |
2107 | } |
2108 | ||
41820509 JM |
2109 | static bfd_boolean |
2110 | elf32_tic6x_new_section_hook (bfd *abfd, asection *sec) | |
2111 | { | |
2112 | bfd_boolean ret; | |
2113 | ||
fbd9ad90 PB |
2114 | /* Allocate target specific section data. */ |
2115 | if (!sec->used_by_bfd) | |
2116 | { | |
2117 | _tic6x_elf_section_data *sdata; | |
2118 | bfd_size_type amt = sizeof (*sdata); | |
2119 | ||
2120 | sdata = (_tic6x_elf_section_data *) bfd_zalloc (abfd, amt); | |
2121 | if (sdata == NULL) | |
2122 | return FALSE; | |
2123 | sec->used_by_bfd = sdata; | |
2124 | } | |
2125 | ||
41820509 JM |
2126 | ret = _bfd_elf_new_section_hook (abfd, sec); |
2127 | sec->use_rela_p = elf32_tic6x_tdata (abfd)->use_rela_p; | |
2128 | ||
2129 | return ret; | |
2130 | } | |
2131 | ||
2132 | /* Return true if relocation REL against section SEC is a REL rather | |
2133 | than RELA relocation. RELOCS is the first relocation in the | |
2134 | section and ABFD is the bfd that contains SEC. */ | |
2135 | ||
2136 | static bfd_boolean | |
2137 | elf32_tic6x_rel_relocation_p (bfd *abfd, asection *sec, | |
2138 | const Elf_Internal_Rela *relocs, | |
2139 | const Elf_Internal_Rela *rel) | |
2140 | { | |
2141 | Elf_Internal_Shdr *rel_hdr; | |
2142 | const struct elf_backend_data *bed; | |
2143 | ||
2144 | /* To determine which flavor of relocation this is, we depend on the | |
d4730f92 BS |
2145 | fact that the INPUT_SECTION's REL_HDR is read before RELA_HDR. */ |
2146 | rel_hdr = elf_section_data (sec)->rel.hdr; | |
2147 | if (rel_hdr == NULL) | |
2148 | return FALSE; | |
41820509 | 2149 | bed = get_elf_backend_data (abfd); |
d4730f92 BS |
2150 | return ((size_t) (rel - relocs) |
2151 | < NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel); | |
41820509 JM |
2152 | } |
2153 | ||
ac145307 BS |
2154 | /* We need dynamic symbols for every section, since segments can |
2155 | relocate independently. */ | |
2156 | static bfd_boolean | |
2157 | elf32_tic6x_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED, | |
2158 | struct bfd_link_info *info ATTRIBUTE_UNUSED, | |
2159 | asection *p) | |
2160 | { | |
2161 | switch (elf_section_data (p)->this_hdr.sh_type) | |
2162 | { | |
2163 | case SHT_PROGBITS: | |
2164 | case SHT_NOBITS: | |
2165 | /* If sh_type is yet undecided, assume it could be | |
2166 | SHT_PROGBITS/SHT_NOBITS. */ | |
2167 | case SHT_NULL: | |
2168 | return FALSE; | |
2169 | ||
2170 | /* There shouldn't be section relative relocations | |
2171 | against any other section. */ | |
2172 | default: | |
2173 | return TRUE; | |
2174 | } | |
2175 | } | |
2176 | ||
40b36596 JM |
2177 | static bfd_boolean |
2178 | elf32_tic6x_relocate_section (bfd *output_bfd, | |
2179 | struct bfd_link_info *info, | |
2180 | bfd *input_bfd, | |
2181 | asection *input_section, | |
2182 | bfd_byte *contents, | |
2183 | Elf_Internal_Rela *relocs, | |
2184 | Elf_Internal_Sym *local_syms, | |
2185 | asection **local_sections) | |
2186 | { | |
ac145307 | 2187 | struct elf32_tic6x_link_hash_table *htab; |
40b36596 JM |
2188 | Elf_Internal_Shdr *symtab_hdr; |
2189 | struct elf_link_hash_entry **sym_hashes; | |
ac145307 | 2190 | bfd_vma *local_got_offsets; |
40b36596 JM |
2191 | Elf_Internal_Rela *rel; |
2192 | Elf_Internal_Rela *relend; | |
2193 | bfd_boolean ok = TRUE; | |
2194 | ||
ac145307 | 2195 | htab = elf32_tic6x_hash_table (info); |
40b36596 JM |
2196 | symtab_hdr = & elf_symtab_hdr (input_bfd); |
2197 | sym_hashes = elf_sym_hashes (input_bfd); | |
ac145307 | 2198 | local_got_offsets = elf_local_got_offsets (input_bfd); |
40b36596 JM |
2199 | |
2200 | relend = relocs + input_section->reloc_count; | |
2201 | ||
2202 | for (rel = relocs; rel < relend; rel ++) | |
2203 | { | |
2204 | int r_type; | |
2205 | unsigned long r_symndx; | |
2206 | arelent bfd_reloc; | |
2207 | reloc_howto_type *howto; | |
2208 | Elf_Internal_Sym *sym; | |
2209 | asection *sec; | |
2210 | struct elf_link_hash_entry *h; | |
4a732032 | 2211 | bfd_vma off, off2, relocation; |
40b36596 JM |
2212 | bfd_boolean unresolved_reloc; |
2213 | bfd_reloc_status_type r; | |
2214 | struct bfd_link_hash_entry *sbh; | |
41820509 | 2215 | bfd_boolean is_rel; |
40b36596 JM |
2216 | |
2217 | r_type = ELF32_R_TYPE (rel->r_info); | |
2218 | r_symndx = ELF32_R_SYM (rel->r_info); | |
2219 | ||
41820509 JM |
2220 | is_rel = elf32_tic6x_rel_relocation_p (input_bfd, input_section, |
2221 | relocs, rel); | |
2222 | ||
2223 | if (is_rel) | |
2224 | elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel); | |
2225 | else | |
2226 | elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel); | |
40b36596 JM |
2227 | howto = bfd_reloc.howto; |
2228 | if (howto == NULL) | |
2229 | { | |
2230 | bfd_set_error (bfd_error_bad_value); | |
2231 | return FALSE; | |
2232 | } | |
2233 | ||
2234 | h = NULL; | |
2235 | sym = NULL; | |
2236 | sec = NULL; | |
2237 | unresolved_reloc = FALSE; | |
2238 | ||
2239 | if (r_symndx < symtab_hdr->sh_info) | |
2240 | { | |
2241 | sym = local_syms + r_symndx; | |
2242 | sec = local_sections[r_symndx]; | |
2243 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); | |
2244 | } | |
2245 | else | |
2246 | { | |
62d887d4 | 2247 | bfd_boolean warned, ignored; |
40b36596 JM |
2248 | |
2249 | RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, | |
2250 | r_symndx, symtab_hdr, sym_hashes, | |
2251 | h, sec, relocation, | |
62d887d4 | 2252 | unresolved_reloc, warned, ignored); |
40b36596 JM |
2253 | } |
2254 | ||
dbaa2011 | 2255 | if (sec != NULL && discarded_section (sec)) |
e4067dbb | 2256 | RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, |
545fd46b | 2257 | rel, 1, relend, howto, 0, contents); |
40b36596 | 2258 | |
0e1862bb | 2259 | if (bfd_link_relocatable (info)) |
41820509 JM |
2260 | { |
2261 | if (is_rel | |
2262 | && sym != NULL | |
2263 | && ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
2264 | { | |
2265 | rel->r_addend = 0; | |
2266 | relocation = sec->output_offset + sym->st_value; | |
2267 | r = _bfd_relocate_contents (howto, input_bfd, relocation, | |
2268 | contents + rel->r_offset); | |
2269 | goto done_reloc; | |
2270 | } | |
2271 | continue; | |
2272 | } | |
40b36596 JM |
2273 | |
2274 | switch (r_type) | |
2275 | { | |
2276 | case R_C6000_NONE: | |
2277 | case R_C6000_ALIGN: | |
2278 | case R_C6000_FPHEAD: | |
2279 | case R_C6000_NOCMP: | |
2280 | /* No action needed. */ | |
2281 | continue; | |
2282 | ||
2283 | case R_C6000_PCR_S21: | |
ac145307 BS |
2284 | /* A branch to an undefined weak symbol is turned into a |
2285 | "b .s2 B3" instruction if the existing insn is of the | |
2286 | form "b .s2 symbol". */ | |
2287 | if (h ? h->root.type == bfd_link_hash_undefweak | |
2288 | && (htab->elf.splt == NULL || h->plt.offset == (bfd_vma) -1) | |
2289 | : r_symndx != STN_UNDEF && bfd_is_und_section (sec)) | |
2290 | { | |
2291 | unsigned long oldval; | |
2292 | oldval = bfd_get_32 (input_bfd, contents + rel->r_offset); | |
2293 | ||
2294 | if ((oldval & 0x7e) == 0x12) | |
2295 | { | |
2296 | oldval &= 0xF0000001; | |
2297 | bfd_put_32 (input_bfd, oldval | 0x000c0362, | |
2298 | contents + rel->r_offset); | |
2299 | r = bfd_reloc_ok; | |
2300 | goto done_reloc; | |
2301 | } | |
2302 | } | |
1a0670f3 | 2303 | /* Fall through. */ |
ac145307 | 2304 | |
40b36596 JM |
2305 | case R_C6000_PCR_S12: |
2306 | case R_C6000_PCR_S10: | |
2307 | case R_C6000_PCR_S7: | |
ac145307 BS |
2308 | if (h != NULL |
2309 | && h->plt.offset != (bfd_vma) -1 | |
2310 | && htab->elf.splt != NULL) | |
2311 | { | |
2312 | relocation = (htab->elf.splt->output_section->vma | |
2313 | + htab->elf.splt->output_offset | |
2314 | + h->plt.offset); | |
2315 | } | |
2316 | ||
40b36596 JM |
2317 | /* Generic PC-relative handling produces a value relative to |
2318 | the exact location of the relocation. Adjust it to be | |
2319 | relative to the start of the fetch packet instead. */ | |
2320 | relocation += (input_section->output_section->vma | |
2321 | + input_section->output_offset | |
2322 | + rel->r_offset) & 0x1f; | |
ac145307 BS |
2323 | unresolved_reloc = FALSE; |
2324 | break; | |
2325 | ||
4a732032 BS |
2326 | case R_C6000_PCR_H16: |
2327 | case R_C6000_PCR_L16: | |
2328 | off = (input_section->output_section->vma | |
2329 | + input_section->output_offset | |
2330 | + rel->r_offset); | |
2331 | /* These must be calculated as R = S - FP(FP(PC) - A). | |
2332 | PC, here, is the value we just computed in OFF. RELOCATION | |
2333 | has the address of S + A. */ | |
2334 | relocation -= rel->r_addend; | |
2335 | off2 = ((off & ~(bfd_vma)0x1f) - rel->r_addend) & (bfd_vma)~0x1f; | |
2336 | off2 = relocation - off2; | |
2337 | relocation = off + off2; | |
2338 | break; | |
2339 | ||
ac145307 BS |
2340 | case R_C6000_DSBT_INDEX: |
2341 | relocation = elf32_tic6x_hash_table (info)->params.dsbt_index; | |
0e1862bb | 2342 | if (!bfd_link_pic (info) || relocation != 0) |
ac145307 BS |
2343 | break; |
2344 | ||
2345 | /* fall through */ | |
40b36596 JM |
2346 | case R_C6000_ABS32: |
2347 | case R_C6000_ABS16: | |
2348 | case R_C6000_ABS8: | |
2349 | case R_C6000_ABS_S16: | |
2350 | case R_C6000_ABS_L16: | |
2351 | case R_C6000_ABS_H16: | |
ac145307 BS |
2352 | /* When generating a shared object or relocatable executable, these |
2353 | relocations are copied into the output file to be resolved at | |
2354 | run time. */ | |
0e1862bb | 2355 | if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd)) |
ac145307 BS |
2356 | && (input_section->flags & SEC_ALLOC) |
2357 | && (h == NULL | |
2358 | || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT | |
2359 | || h->root.type != bfd_link_hash_undefweak)) | |
2360 | { | |
2361 | Elf_Internal_Rela outrel; | |
2362 | bfd_boolean skip, relocate; | |
2363 | asection *sreloc; | |
2364 | ||
2365 | unresolved_reloc = FALSE; | |
2366 | ||
2367 | sreloc = elf_section_data (input_section)->sreloc; | |
2368 | BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL); | |
2369 | ||
2370 | skip = FALSE; | |
2371 | relocate = FALSE; | |
2372 | ||
2373 | outrel.r_offset = | |
2374 | _bfd_elf_section_offset (output_bfd, info, input_section, | |
2375 | rel->r_offset); | |
2376 | if (outrel.r_offset == (bfd_vma) -1) | |
2377 | skip = TRUE; | |
2378 | else if (outrel.r_offset == (bfd_vma) -2) | |
2379 | skip = TRUE, relocate = TRUE; | |
2380 | outrel.r_offset += (input_section->output_section->vma | |
2381 | + input_section->output_offset); | |
2382 | ||
2383 | if (skip) | |
2384 | memset (&outrel, 0, sizeof outrel); | |
2385 | else if (h != NULL | |
2386 | && h->dynindx != -1 | |
0e1862bb | 2387 | && (!bfd_link_pic (info) |
a496fbc8 | 2388 | || !SYMBOLIC_BIND (info, h) |
ac145307 BS |
2389 | || !h->def_regular)) |
2390 | { | |
2391 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); | |
2392 | outrel.r_addend = rel->r_addend; | |
2393 | } | |
2394 | else | |
2395 | { | |
2396 | long indx; | |
2397 | ||
2398 | outrel.r_addend = relocation + rel->r_addend; | |
2399 | ||
2400 | if (bfd_is_abs_section (sec)) | |
2401 | indx = 0; | |
2402 | else if (sec == NULL || sec->owner == NULL) | |
2403 | { | |
2404 | bfd_set_error (bfd_error_bad_value); | |
2405 | return FALSE; | |
2406 | } | |
2407 | else | |
2408 | { | |
2409 | asection *osec; | |
2410 | ||
2411 | osec = sec->output_section; | |
2412 | indx = elf_section_data (osec)->dynindx; | |
2413 | outrel.r_addend -= osec->vma; | |
2414 | BFD_ASSERT (indx != 0); | |
2415 | } | |
2416 | ||
2417 | outrel.r_info = ELF32_R_INFO (indx, r_type); | |
2418 | } | |
2419 | ||
2420 | elf32_tic6x_install_rela (output_bfd, sreloc, &outrel); | |
2421 | ||
2422 | /* If this reloc is against an external symbol, we do not want to | |
2423 | fiddle with the addend. Otherwise, we need to include the symbol | |
2424 | value so that it becomes an addend for the dynamic reloc. */ | |
2425 | if (! relocate) | |
2426 | continue; | |
2427 | } | |
2428 | ||
40b36596 JM |
2429 | /* Generic logic OK. */ |
2430 | break; | |
2431 | ||
2432 | case R_C6000_SBR_U15_B: | |
2433 | case R_C6000_SBR_U15_H: | |
2434 | case R_C6000_SBR_U15_W: | |
2435 | case R_C6000_SBR_S16: | |
2436 | case R_C6000_SBR_L16_B: | |
2437 | case R_C6000_SBR_L16_H: | |
2438 | case R_C6000_SBR_L16_W: | |
2439 | case R_C6000_SBR_H16_B: | |
2440 | case R_C6000_SBR_H16_H: | |
2441 | case R_C6000_SBR_H16_W: | |
2442 | sbh = bfd_link_hash_lookup (info->hash, "__c6xabi_DSBT_BASE", | |
2443 | FALSE, FALSE, TRUE); | |
2444 | if (sbh != NULL | |
2445 | && (sbh->type == bfd_link_hash_defined | |
2446 | || sbh->type == bfd_link_hash_defweak)) | |
ac145307 BS |
2447 | { |
2448 | if (h ? (h->root.type == bfd_link_hash_undefweak | |
2449 | && (htab->elf.splt == NULL | |
2450 | || h->plt.offset == (bfd_vma) -1)) | |
2451 | : r_symndx != STN_UNDEF && bfd_is_und_section (sec)) | |
2452 | relocation = 0; | |
2453 | else | |
2454 | relocation -= (sbh->u.def.value | |
2455 | + sbh->u.def.section->output_section->vma | |
2456 | + sbh->u.def.section->output_offset); | |
2457 | } | |
40b36596 JM |
2458 | else |
2459 | { | |
871b3ab2 | 2460 | _bfd_error_handler (_("%pB: SB-relative relocation but " |
4eca0228 AM |
2461 | "__c6xabi_DSBT_BASE not defined"), |
2462 | input_bfd); | |
40b36596 JM |
2463 | ok = FALSE; |
2464 | continue; | |
2465 | } | |
2466 | break; | |
2467 | ||
2468 | case R_C6000_SBR_GOT_U15_W: | |
2469 | case R_C6000_SBR_GOT_L16_W: | |
2470 | case R_C6000_SBR_GOT_H16_W: | |
2fbb87f6 | 2471 | case R_C6000_EHTYPE: |
ac145307 BS |
2472 | /* Relocation is to the entry for this symbol in the global |
2473 | offset table. */ | |
2474 | if (htab->elf.sgot == NULL) | |
2475 | abort (); | |
2476 | ||
2477 | if (h != NULL) | |
2478 | { | |
2479 | bfd_boolean dyn; | |
2480 | ||
2481 | off = h->got.offset; | |
2482 | dyn = htab->elf.dynamic_sections_created; | |
0e1862bb L |
2483 | if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, |
2484 | bfd_link_pic (info), | |
2485 | h) | |
2486 | || (bfd_link_pic (info) | |
ac145307 BS |
2487 | && SYMBOL_REFERENCES_LOCAL (info, h)) |
2488 | || (ELF_ST_VISIBILITY (h->other) | |
2489 | && h->root.type == bfd_link_hash_undefweak)) | |
2490 | { | |
2491 | /* This is actually a static link, or it is a | |
2492 | -Bsymbolic link and the symbol is defined | |
2493 | locally, or the symbol was forced to be local | |
2494 | because of a version file. We must initialize | |
2495 | this entry in the global offset table. Since the | |
2496 | offset must always be a multiple of 4, we use the | |
2497 | least significant bit to record whether we have | |
2498 | initialized it already. | |
2499 | ||
2500 | When doing a dynamic link, we create a .rel.got | |
2501 | relocation entry to initialize the value. This | |
2502 | is done in the finish_dynamic_symbol routine. */ | |
2503 | if ((off & 1) != 0) | |
2504 | off &= ~1; | |
2505 | else | |
2506 | { | |
2507 | bfd_put_32 (output_bfd, relocation, | |
2508 | htab->elf.sgot->contents + off); | |
2509 | h->got.offset |= 1; | |
2510 | ||
0e1862bb L |
2511 | if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, |
2512 | bfd_link_pic (info), | |
ac145307 BS |
2513 | h) |
2514 | && !(ELF_ST_VISIBILITY (h->other) | |
2515 | && h->root.type == bfd_link_hash_undefweak)) | |
2516 | elf32_tic6x_make_got_dynreloc (output_bfd, htab, sec, | |
2517 | off); | |
2518 | } | |
2519 | } | |
2520 | else | |
2521 | unresolved_reloc = FALSE; | |
2522 | } | |
2523 | else | |
2524 | { | |
2525 | if (local_got_offsets == NULL) | |
2526 | abort (); | |
2527 | ||
2528 | off = local_got_offsets[r_symndx]; | |
2529 | ||
2530 | /* The offset must always be a multiple of 4. We use | |
2531 | the least significant bit to record whether we have | |
2532 | already generated the necessary reloc. */ | |
2533 | if ((off & 1) != 0) | |
2534 | off &= ~1; | |
2535 | else | |
2536 | { | |
2537 | bfd_put_32 (output_bfd, relocation, | |
2538 | htab->elf.sgot->contents + off); | |
2539 | ||
0e1862bb | 2540 | if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd)) |
ac145307 BS |
2541 | elf32_tic6x_make_got_dynreloc (output_bfd, htab, sec, off); |
2542 | ||
2543 | local_got_offsets[r_symndx] |= 1; | |
2544 | } | |
2545 | } | |
2546 | ||
2547 | if (off >= (bfd_vma) -2) | |
2548 | abort (); | |
2549 | ||
2550 | if (htab->dsbt) | |
2551 | relocation = (htab->elf.sgot->output_section->vma | |
2552 | + htab->elf.sgot->output_offset + off | |
2553 | - htab->dsbt->output_section->vma | |
2554 | - htab->dsbt->output_offset); | |
2555 | else | |
2556 | relocation = (htab->elf.sgot->output_section->vma | |
2557 | + htab->elf.sgot->output_offset + off | |
2558 | - htab->elf.sgotplt->output_section->vma | |
2559 | - htab->elf.sgotplt->output_offset); | |
2560 | ||
2561 | if (rel->r_addend != 0) | |
2562 | { | |
2563 | /* We can't do anything for a relocation which is against | |
2564 | a symbol *plus offset*. GOT holds relocations for | |
2565 | symbols. Make this an error; the compiler isn't | |
2566 | allowed to pass us these kinds of things. */ | |
2567 | if (h == NULL) | |
4eca0228 | 2568 | _bfd_error_handler |
695344c0 | 2569 | /* xgettext:c-format */ |
2dcf00ce AM |
2570 | (_("%pB, section %pA: relocation %s with non-zero addend %" |
2571 | PRId64 " against local symbol"), | |
ac145307 BS |
2572 | input_bfd, |
2573 | input_section, | |
2574 | elf32_tic6x_howto_table[r_type].name, | |
2dcf00ce | 2575 | (int64_t) rel->r_addend); |
ac145307 | 2576 | else |
4eca0228 | 2577 | _bfd_error_handler |
695344c0 | 2578 | /* xgettext:c-format */ |
2dcf00ce AM |
2579 | (_("%pB, section %pA: relocation %s with non-zero addend %" |
2580 | PRId64 " against symbol `%s'"), | |
ac145307 BS |
2581 | input_bfd, |
2582 | input_section, | |
2583 | elf32_tic6x_howto_table[r_type].name, | |
2dcf00ce | 2584 | (int64_t) rel->r_addend, |
ac145307 BS |
2585 | h->root.root.string[0] != '\0' ? h->root.root.string |
2586 | : _("[whose name is lost]")); | |
2587 | ||
2588 | bfd_set_error (bfd_error_bad_value); | |
2589 | return FALSE; | |
2590 | } | |
2591 | break; | |
2592 | ||
40b36596 | 2593 | case R_C6000_PREL31: |
44e87ece PB |
2594 | if (h != NULL |
2595 | && h->plt.offset != (bfd_vma) -1 | |
2596 | && htab->elf.splt != NULL) | |
2597 | { | |
2598 | relocation = (htab->elf.splt->output_section->vma | |
2599 | + htab->elf.splt->output_offset | |
2600 | + h->plt.offset); | |
2601 | } | |
2602 | break; | |
40b36596 JM |
2603 | |
2604 | case R_C6000_COPY: | |
2605 | /* Invalid in relocatable object. */ | |
2606 | default: | |
2607 | /* Unknown relocation. */ | |
695344c0 | 2608 | /* xgettext:c-format */ |
871b3ab2 | 2609 | _bfd_error_handler (_("%pB: invalid relocation type %d"), |
4eca0228 | 2610 | input_bfd, r_type); |
40b36596 JM |
2611 | ok = FALSE; |
2612 | continue; | |
2613 | } | |
2614 | ||
2615 | r = _bfd_final_link_relocate (howto, input_bfd, input_section, | |
2616 | contents, rel->r_offset, | |
2617 | relocation, rel->r_addend); | |
2618 | ||
41820509 | 2619 | done_reloc: |
40b36596 JM |
2620 | if (r == bfd_reloc_ok |
2621 | && howto->complain_on_overflow == complain_overflow_bitfield) | |
2622 | { | |
2623 | /* Generic overflow handling accepts cases the ABI says | |
2624 | should be rejected for R_C6000_ABS16 and | |
2625 | R_C6000_ABS8. */ | |
2626 | bfd_vma value = (relocation + rel->r_addend) & 0xffffffff; | |
2627 | bfd_vma sbit = 1 << (howto->bitsize - 1); | |
2628 | bfd_vma sbits = (-(bfd_vma) sbit) & 0xffffffff; | |
2629 | bfd_vma value_sbits = value & sbits; | |
2630 | ||
2631 | if (value_sbits != 0 | |
2632 | && value_sbits != sbit | |
2633 | && value_sbits != sbits) | |
2634 | r = bfd_reloc_overflow; | |
2635 | } | |
2636 | ||
2637 | if (r != bfd_reloc_ok) | |
2638 | { | |
2639 | const char *name; | |
2640 | const char *error_message; | |
2641 | ||
2642 | if (h != NULL) | |
2643 | name = h->root.root.string; | |
2644 | else | |
2645 | { | |
2646 | name = bfd_elf_string_from_elf_section (input_bfd, | |
2647 | symtab_hdr->sh_link, | |
2648 | sym->st_name); | |
2649 | if (name == NULL) | |
2650 | return FALSE; | |
2651 | if (*name == '\0') | |
2652 | name = bfd_section_name (input_bfd, sec); | |
2653 | } | |
2654 | ||
2655 | switch (r) | |
2656 | { | |
2657 | case bfd_reloc_overflow: | |
2658 | /* If the overflowing reloc was to an undefined symbol, | |
2659 | we have already printed one error message and there | |
2660 | is no point complaining again. */ | |
1a72702b AM |
2661 | if (!h || h->root.type != bfd_link_hash_undefined) |
2662 | (*info->callbacks->reloc_overflow) | |
2663 | (info, (h ? &h->root : NULL), name, howto->name, | |
2664 | (bfd_vma) 0, input_bfd, input_section, rel->r_offset); | |
40b36596 JM |
2665 | break; |
2666 | ||
2667 | case bfd_reloc_undefined: | |
1a72702b AM |
2668 | (*info->callbacks->undefined_symbol) (info, name, input_bfd, |
2669 | input_section, | |
2670 | rel->r_offset, TRUE); | |
40b36596 JM |
2671 | break; |
2672 | ||
2673 | case bfd_reloc_outofrange: | |
2674 | error_message = _("out of range"); | |
2675 | goto common_error; | |
2676 | ||
2677 | case bfd_reloc_notsupported: | |
2678 | error_message = _("unsupported relocation"); | |
2679 | goto common_error; | |
2680 | ||
2681 | case bfd_reloc_dangerous: | |
2682 | error_message = _("dangerous relocation"); | |
2683 | goto common_error; | |
2684 | ||
2685 | default: | |
2686 | error_message = _("unknown error"); | |
2687 | /* Fall through. */ | |
2688 | ||
2689 | common_error: | |
2690 | BFD_ASSERT (error_message != NULL); | |
1a72702b AM |
2691 | (*info->callbacks->reloc_dangerous) |
2692 | (info, error_message, input_bfd, input_section, rel->r_offset); | |
40b36596 JM |
2693 | break; |
2694 | } | |
2695 | } | |
2696 | } | |
2697 | ||
2698 | return ok; | |
2699 | } | |
2700 | ||
ac145307 BS |
2701 | \f |
2702 | /* Look through the relocs for a section during the first phase, and | |
2703 | calculate needed space in the global offset table, procedure linkage | |
2704 | table, and dynamic reloc sections. */ | |
2705 | ||
2706 | static bfd_boolean | |
2707 | elf32_tic6x_check_relocs (bfd *abfd, struct bfd_link_info *info, | |
2708 | asection *sec, const Elf_Internal_Rela *relocs) | |
2709 | { | |
2710 | struct elf32_tic6x_link_hash_table *htab; | |
2711 | Elf_Internal_Shdr *symtab_hdr; | |
2712 | struct elf_link_hash_entry **sym_hashes; | |
2713 | const Elf_Internal_Rela *rel; | |
2714 | const Elf_Internal_Rela *rel_end; | |
2715 | asection *sreloc; | |
2716 | ||
0e1862bb | 2717 | if (bfd_link_relocatable (info)) |
ac145307 BS |
2718 | return TRUE; |
2719 | ||
2720 | htab = elf32_tic6x_hash_table (info); | |
2721 | symtab_hdr = &elf_symtab_hdr (abfd); | |
2722 | sym_hashes = elf_sym_hashes (abfd); | |
2723 | ||
2724 | /* Create dynamic sections for relocatable executables so that we can | |
2725 | copy relocations. */ | |
0e1862bb | 2726 | if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (abfd)) |
ac145307 BS |
2727 | && ! htab->elf.dynamic_sections_created) |
2728 | { | |
2729 | if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) | |
2730 | return FALSE; | |
2731 | } | |
2732 | ||
2733 | sreloc = NULL; | |
2734 | ||
2735 | rel_end = relocs + sec->reloc_count; | |
2736 | for (rel = relocs; rel < rel_end; rel++) | |
2737 | { | |
2738 | unsigned int r_type; | |
d42c267e | 2739 | unsigned int r_symndx; |
ac145307 BS |
2740 | struct elf_link_hash_entry *h; |
2741 | Elf_Internal_Sym *isym; | |
2742 | ||
2743 | r_symndx = ELF32_R_SYM (rel->r_info); | |
2744 | r_type = ELF32_R_TYPE (rel->r_info); | |
2745 | ||
2746 | if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) | |
2747 | { | |
695344c0 | 2748 | /* xgettext:c-format */ |
871b3ab2 | 2749 | _bfd_error_handler (_("%pB: bad symbol index: %d"), |
4eca0228 | 2750 | abfd, r_symndx); |
ac145307 BS |
2751 | return FALSE; |
2752 | } | |
2753 | ||
2754 | if (r_symndx < symtab_hdr->sh_info) | |
2755 | { | |
2756 | /* A local symbol. */ | |
2757 | isym = bfd_sym_from_r_symndx (&htab->sym_cache, | |
2758 | abfd, r_symndx); | |
2759 | if (isym == NULL) | |
2760 | return FALSE; | |
2761 | h = NULL; | |
2762 | } | |
2763 | else | |
2764 | { | |
2765 | isym = NULL; | |
2766 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
2767 | while (h->root.type == bfd_link_hash_indirect | |
2768 | || h->root.type == bfd_link_hash_warning) | |
2769 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
2770 | } | |
2771 | ||
2772 | switch (r_type) | |
2773 | { | |
2774 | case R_C6000_PCR_S21: | |
44e87ece | 2775 | case R_C6000_PREL31: |
ac145307 BS |
2776 | /* This symbol requires a procedure linkage table entry. We |
2777 | actually build the entry in adjust_dynamic_symbol, | |
2778 | because this might be a case of linking PIC code which is | |
2779 | never referenced by a dynamic object, in which case we | |
2780 | don't need to generate a procedure linkage table entry | |
2781 | after all. */ | |
2782 | ||
2783 | /* If this is a local symbol, we resolve it directly without | |
2784 | creating a procedure linkage table entry. */ | |
2785 | if (h == NULL) | |
2786 | continue; | |
2787 | ||
2788 | h->needs_plt = 1; | |
2789 | h->plt.refcount += 1; | |
2790 | break; | |
2791 | ||
2792 | case R_C6000_SBR_GOT_U15_W: | |
2793 | case R_C6000_SBR_GOT_L16_W: | |
2794 | case R_C6000_SBR_GOT_H16_W: | |
2fbb87f6 | 2795 | case R_C6000_EHTYPE: |
ac145307 BS |
2796 | /* This symbol requires a global offset table entry. */ |
2797 | if (h != NULL) | |
2798 | { | |
2799 | h->got.refcount += 1; | |
2800 | } | |
2801 | else | |
2802 | { | |
2803 | bfd_signed_vma *local_got_refcounts; | |
2804 | ||
2805 | /* This is a global offset table entry for a local symbol. */ | |
2806 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
2807 | if (local_got_refcounts == NULL) | |
2808 | { | |
2809 | bfd_size_type size; | |
2810 | ||
2811 | size = symtab_hdr->sh_info; | |
2812 | size *= (sizeof (bfd_signed_vma) | |
2813 | + sizeof (bfd_vma) + sizeof(char)); | |
2814 | local_got_refcounts = bfd_zalloc (abfd, size); | |
2815 | if (local_got_refcounts == NULL) | |
2816 | return FALSE; | |
2817 | elf_local_got_refcounts (abfd) = local_got_refcounts; | |
2818 | } | |
2819 | local_got_refcounts[r_symndx] += 1; | |
2820 | } | |
2821 | ||
2822 | if (htab->elf.sgot == NULL) | |
2823 | { | |
2824 | if (htab->elf.dynobj == NULL) | |
2825 | htab->elf.dynobj = abfd; | |
2826 | if (!_bfd_elf_create_got_section (htab->elf.dynobj, info)) | |
2827 | return FALSE; | |
2828 | } | |
2829 | break; | |
2830 | ||
2831 | case R_C6000_DSBT_INDEX: | |
2832 | /* We'd like to check for nonzero dsbt_index here, but it's | |
2833 | set up only after check_relocs is called. Instead, we | |
2834 | store the number of R_C6000_DSBT_INDEX relocs in the | |
2835 | pc_count field, and potentially discard the extra space | |
2836 | in elf32_tic6x_allocate_dynrelocs. */ | |
0e1862bb | 2837 | if (!bfd_link_pic (info)) |
ac145307 BS |
2838 | break; |
2839 | ||
2840 | /* fall through */ | |
2841 | case R_C6000_ABS32: | |
2842 | case R_C6000_ABS16: | |
2843 | case R_C6000_ABS8: | |
2844 | case R_C6000_ABS_S16: | |
2845 | case R_C6000_ABS_L16: | |
2846 | case R_C6000_ABS_H16: | |
2847 | /* If we are creating a shared library, and this is a reloc | |
2848 | against a global symbol, or a non PC relative reloc | |
2849 | against a local symbol, then we need to copy the reloc | |
2850 | into the shared library. However, if we are linking with | |
2851 | -Bsymbolic, we do not need to copy a reloc against a | |
2852 | global symbol which is defined in an object we are | |
2853 | including in the link (i.e., DEF_REGULAR is set). At | |
2854 | this point we have not seen all the input files, so it is | |
2855 | possible that DEF_REGULAR is not set now but will be set | |
2856 | later (it is never cleared). In case of a weak definition, | |
2857 | DEF_REGULAR may be cleared later by a strong definition in | |
2858 | a shared library. We account for that possibility below by | |
2859 | storing information in the relocs_copied field of the hash | |
2860 | table entry. A similar situation occurs when creating | |
2861 | shared libraries and symbol visibility changes render the | |
2862 | symbol local. | |
2863 | ||
2864 | If on the other hand, we are creating an executable, we | |
2865 | may need to keep relocations for symbols satisfied by a | |
2866 | dynamic library if we manage to avoid copy relocs for the | |
2867 | symbol. */ | |
0e1862bb | 2868 | if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (abfd)) |
ac145307 BS |
2869 | && (sec->flags & SEC_ALLOC) != 0) |
2870 | { | |
2871 | struct elf_dyn_relocs *p; | |
2872 | struct elf_dyn_relocs **head; | |
2873 | ||
2874 | /* We must copy these reloc types into the output file. | |
2875 | Create a reloc section in dynobj and make room for | |
2876 | this reloc. */ | |
2877 | if (sreloc == NULL) | |
2878 | { | |
2879 | if (htab->elf.dynobj == NULL) | |
2880 | htab->elf.dynobj = abfd; | |
2881 | ||
2882 | sreloc = _bfd_elf_make_dynamic_reloc_section | |
2883 | (sec, htab->elf.dynobj, 2, abfd, /*rela? */ TRUE); | |
2884 | ||
2885 | if (sreloc == NULL) | |
2886 | return FALSE; | |
2887 | } | |
2888 | ||
2889 | /* If this is a global symbol, we count the number of | |
2890 | relocations we need for this symbol. */ | |
2891 | if (h != NULL) | |
2892 | { | |
2893 | head = &((struct elf32_tic6x_link_hash_entry *) h)->dyn_relocs; | |
2894 | } | |
2895 | else | |
2896 | { | |
2897 | /* Track dynamic relocs needed for local syms too. | |
2898 | We really need local syms available to do this | |
2899 | easily. Oh well. */ | |
2900 | void **vpp; | |
2901 | asection *s; | |
2902 | ||
2903 | s = bfd_section_from_elf_index (abfd, isym->st_shndx); | |
2904 | if (s == NULL) | |
2905 | s = sec; | |
2906 | ||
2907 | vpp = &elf_section_data (s)->local_dynrel; | |
2908 | head = (struct elf_dyn_relocs **)vpp; | |
2909 | } | |
2910 | ||
2911 | p = *head; | |
2912 | if (p == NULL || p->sec != sec) | |
2913 | { | |
2914 | bfd_size_type amt = sizeof *p; | |
2915 | p = bfd_alloc (htab->elf.dynobj, amt); | |
2916 | if (p == NULL) | |
2917 | return FALSE; | |
2918 | p->next = *head; | |
2919 | *head = p; | |
2920 | p->sec = sec; | |
2921 | p->count = 0; | |
2123f9ad | 2922 | p->pc_count = 0; |
ac145307 BS |
2923 | } |
2924 | ||
2925 | p->count += 1; | |
2926 | if (r_type == R_C6000_DSBT_INDEX) | |
2927 | p->pc_count += 1; | |
2928 | } | |
2929 | break; | |
2930 | ||
2931 | case R_C6000_SBR_U15_B: | |
2932 | case R_C6000_SBR_U15_H: | |
2933 | case R_C6000_SBR_U15_W: | |
2934 | case R_C6000_SBR_S16: | |
2935 | case R_C6000_SBR_L16_B: | |
2936 | case R_C6000_SBR_L16_H: | |
2937 | case R_C6000_SBR_L16_W: | |
2938 | case R_C6000_SBR_H16_B: | |
2939 | case R_C6000_SBR_H16_H: | |
2940 | case R_C6000_SBR_H16_W: | |
0e1862bb | 2941 | if (h != NULL && bfd_link_executable (info)) |
ac145307 BS |
2942 | { |
2943 | /* For B14-relative addresses, we might need a copy | |
2944 | reloc. */ | |
2945 | h->non_got_ref = 1; | |
2946 | } | |
2947 | break; | |
2948 | ||
2949 | default: | |
2950 | break; | |
2951 | } | |
2952 | } | |
2953 | ||
2954 | return TRUE; | |
2955 | } | |
2956 | ||
2957 | static bfd_boolean | |
2958 | elf32_tic6x_add_symbol_hook (bfd *abfd, | |
2959 | struct bfd_link_info *info ATTRIBUTE_UNUSED, | |
2960 | Elf_Internal_Sym *sym, | |
2961 | const char **namep ATTRIBUTE_UNUSED, | |
2962 | flagword *flagsp ATTRIBUTE_UNUSED, | |
2963 | asection **secp, | |
2964 | bfd_vma *valp) | |
2965 | { | |
2966 | switch (sym->st_shndx) | |
2967 | { | |
2968 | case SHN_TIC6X_SCOMMON: | |
2969 | *secp = bfd_make_section_old_way (abfd, ".scommon"); | |
2970 | (*secp)->flags |= SEC_IS_COMMON; | |
2971 | *valp = sym->st_size; | |
a253d456 | 2972 | (void) bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value)); |
ac145307 BS |
2973 | break; |
2974 | } | |
2975 | ||
2976 | return TRUE; | |
2977 | } | |
2978 | ||
2979 | static void | |
2980 | elf32_tic6x_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym) | |
2981 | { | |
2982 | elf_symbol_type *elfsym; | |
2983 | ||
2984 | elfsym = (elf_symbol_type *) asym; | |
2985 | switch (elfsym->internal_elf_sym.st_shndx) | |
2986 | { | |
2987 | case SHN_TIC6X_SCOMMON: | |
2988 | if (tic6x_elf_scom_section.name == NULL) | |
07d6d2b8 AM |
2989 | { |
2990 | /* Initialize the small common section. */ | |
2991 | tic6x_elf_scom_section.name = ".scommon"; | |
2992 | tic6x_elf_scom_section.flags = SEC_IS_COMMON; | |
2993 | tic6x_elf_scom_section.output_section = &tic6x_elf_scom_section; | |
2994 | tic6x_elf_scom_section.symbol = &tic6x_elf_scom_symbol; | |
2995 | tic6x_elf_scom_section.symbol_ptr_ptr = &tic6x_elf_scom_symbol_ptr; | |
2996 | tic6x_elf_scom_symbol.name = ".scommon"; | |
2997 | tic6x_elf_scom_symbol.flags = BSF_SECTION_SYM; | |
2998 | tic6x_elf_scom_symbol.section = &tic6x_elf_scom_section; | |
2999 | tic6x_elf_scom_symbol_ptr = &tic6x_elf_scom_symbol; | |
3000 | } | |
ac145307 BS |
3001 | asym->section = &tic6x_elf_scom_section; |
3002 | asym->value = elfsym->internal_elf_sym.st_size; | |
3003 | break; | |
3004 | } | |
3005 | } | |
3006 | ||
3007 | static int | |
3008 | elf32_tic6x_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED, | |
3009 | const char *name ATTRIBUTE_UNUSED, | |
3010 | Elf_Internal_Sym *sym, | |
3011 | asection *input_sec, | |
3012 | struct elf_link_hash_entry *h ATTRIBUTE_UNUSED) | |
3013 | { | |
3014 | /* If we see a common symbol, which implies a relocatable link, then | |
3015 | if a symbol was small common in an input file, mark it as small | |
3016 | common in the output file. */ | |
3017 | if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0) | |
3018 | sym->st_shndx = SHN_TIC6X_SCOMMON; | |
3019 | ||
3020 | return 1; | |
3021 | } | |
3022 | ||
3023 | static bfd_boolean | |
3024 | elf32_tic6x_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED, | |
3025 | asection *sec, | |
3026 | int *retval) | |
3027 | { | |
3028 | if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0) | |
3029 | { | |
3030 | *retval = SHN_TIC6X_SCOMMON; | |
3031 | return TRUE; | |
3032 | } | |
3033 | ||
3034 | return FALSE; | |
3035 | } | |
3036 | ||
3037 | /* Allocate space in .plt, .got and associated reloc sections for | |
3038 | dynamic relocs. */ | |
3039 | ||
3040 | static bfd_boolean | |
3041 | elf32_tic6x_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) | |
3042 | { | |
3043 | struct bfd_link_info *info; | |
3044 | struct elf32_tic6x_link_hash_table *htab; | |
3045 | struct elf32_tic6x_link_hash_entry *eh; | |
3046 | struct elf_dyn_relocs *p; | |
3047 | ||
3048 | if (h->root.type == bfd_link_hash_indirect) | |
3049 | return TRUE; | |
3050 | ||
ac145307 | 3051 | eh = (struct elf32_tic6x_link_hash_entry *) h; |
ac145307 BS |
3052 | info = (struct bfd_link_info *) inf; |
3053 | htab = elf32_tic6x_hash_table (info); | |
3054 | ||
3055 | if (htab->elf.dynamic_sections_created && h->plt.refcount > 0) | |
3056 | { | |
3057 | /* Make sure this symbol is output as a dynamic symbol. | |
3058 | Undefined weak syms won't yet be marked as dynamic. */ | |
3059 | if (h->dynindx == -1 && !h->forced_local) | |
3060 | { | |
3061 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) | |
3062 | return FALSE; | |
3063 | } | |
3064 | ||
0e1862bb | 3065 | if (bfd_link_pic (info) |
ac145307 BS |
3066 | || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) |
3067 | { | |
3068 | asection *s = htab->elf.splt; | |
3069 | ||
3070 | /* If this is the first .plt entry, make room for the special | |
3071 | first entry. */ | |
3072 | if (s->size == 0) | |
3073 | s->size += PLT_ENTRY_SIZE; | |
3074 | ||
3075 | h->plt.offset = s->size; | |
3076 | ||
3077 | /* If this symbol is not defined in a regular file, and we are | |
3078 | not generating a shared library, then set the symbol to this | |
3079 | location in the .plt. This is required to make function | |
3080 | pointers compare as equal between the normal executable and | |
3081 | the shared library. */ | |
0e1862bb | 3082 | if (! bfd_link_pic (info) && !h->def_regular) |
ac145307 BS |
3083 | { |
3084 | h->root.u.def.section = s; | |
3085 | h->root.u.def.value = h->plt.offset; | |
3086 | } | |
3087 | ||
3088 | /* Make room for this entry. */ | |
3089 | s->size += PLT_ENTRY_SIZE; | |
3090 | /* We also need to make an entry in the .got.plt section, which | |
3091 | will be placed in the .got section by the linker script. */ | |
3092 | htab->elf.sgotplt->size += 4; | |
3093 | /* We also need to make an entry in the .rel.plt section. */ | |
3094 | htab->elf.srelplt->size += sizeof (Elf32_External_Rela); | |
3095 | } | |
3096 | else | |
3097 | { | |
3098 | h->plt.offset = (bfd_vma) -1; | |
3099 | h->needs_plt = 0; | |
3100 | } | |
3101 | } | |
3102 | else | |
3103 | { | |
3104 | h->plt.offset = (bfd_vma) -1; | |
3105 | h->needs_plt = 0; | |
3106 | } | |
3107 | ||
3108 | if (h->got.refcount > 0) | |
3109 | { | |
3110 | asection *s; | |
3111 | ||
3112 | /* Make sure this symbol is output as a dynamic symbol. | |
3113 | Undefined weak syms won't yet be marked as dynamic. */ | |
3114 | if (h->dynindx == -1 | |
3115 | && !h->forced_local) | |
3116 | { | |
3117 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) | |
3118 | return FALSE; | |
3119 | } | |
3120 | ||
3121 | s = htab->elf.sgot; | |
3122 | h->got.offset = s->size; | |
3123 | s->size += 4; | |
3124 | ||
3125 | if (!(ELF_ST_VISIBILITY (h->other) | |
3126 | && h->root.type == bfd_link_hash_undefweak)) | |
3127 | htab->elf.srelgot->size += sizeof (Elf32_External_Rela); | |
3128 | } | |
3129 | else | |
3130 | h->got.offset = (bfd_vma) -1; | |
3131 | ||
3132 | if (eh->dyn_relocs == NULL) | |
3133 | return TRUE; | |
3134 | ||
3135 | /* Discard relocs on undefined weak syms with non-default | |
3136 | visibility. */ | |
0e1862bb | 3137 | if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (htab->obfd)) |
ac145307 BS |
3138 | { |
3139 | /* We use the pc_count field to hold the number of | |
3140 | R_C6000_DSBT_INDEX relocs. */ | |
3141 | if (htab->params.dsbt_index != 0) | |
3142 | { | |
3143 | struct elf_dyn_relocs **pp; | |
3144 | ||
3145 | for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) | |
3146 | { | |
3147 | p->count -= p->pc_count; | |
3148 | p->pc_count = 0; | |
3149 | if (p->count == 0) | |
3150 | *pp = p->next; | |
3151 | else | |
3152 | pp = &p->next; | |
3153 | } | |
3154 | } | |
3155 | ||
3156 | if (eh->dyn_relocs != NULL | |
3157 | && h->root.type == bfd_link_hash_undefweak) | |
3158 | { | |
3159 | if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) | |
3160 | eh->dyn_relocs = NULL; | |
3161 | ||
3162 | /* Make sure undefined weak symbols are output as a dynamic | |
3163 | symbol in PIEs. */ | |
3164 | else if (h->dynindx == -1 | |
3165 | && !h->forced_local) | |
3166 | { | |
3167 | if (! bfd_elf_link_record_dynamic_symbol (info, h)) | |
3168 | return FALSE; | |
3169 | } | |
3170 | } | |
3171 | } | |
3172 | ||
3173 | /* Finally, allocate space. */ | |
3174 | for (p = eh->dyn_relocs; p != NULL; p = p->next) | |
3175 | { | |
3176 | asection *sreloc; | |
3177 | ||
3178 | sreloc = elf_section_data (p->sec)->sreloc; | |
3179 | ||
3180 | BFD_ASSERT (sreloc != NULL); | |
3181 | sreloc->size += p->count * sizeof (Elf32_External_Rela); | |
3182 | } | |
3183 | ||
3184 | return TRUE; | |
3185 | } | |
3186 | ||
63c1f59d AM |
3187 | /* Set DF_TEXTREL if we find any dynamic relocs that apply to |
3188 | read-only sections. */ | |
ac145307 BS |
3189 | |
3190 | static bfd_boolean | |
63c1f59d | 3191 | maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) |
ac145307 | 3192 | { |
63c1f59d | 3193 | asection *sec; |
ac145307 | 3194 | |
63c1f59d AM |
3195 | if (h->root.type == bfd_link_hash_indirect) |
3196 | return TRUE; | |
ac145307 | 3197 | |
63c1f59d AM |
3198 | sec = readonly_dynrelocs (h); |
3199 | if (sec != NULL) | |
3200 | { | |
3201 | struct bfd_link_info *info = (struct bfd_link_info *) info_p; | |
ac145307 | 3202 | |
63c1f59d AM |
3203 | info->flags |= DF_TEXTREL; |
3204 | info->callbacks->minfo | |
c1c8c1ef | 3205 | (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), |
63c1f59d | 3206 | sec->owner, h->root.root.string, sec); |
ac145307 | 3207 | |
63c1f59d AM |
3208 | /* Not an error, just cut short the traversal. */ |
3209 | return FALSE; | |
ac145307 BS |
3210 | } |
3211 | return TRUE; | |
3212 | } | |
3213 | ||
3214 | /* Set the sizes of the dynamic sections. */ | |
3215 | ||
3216 | static bfd_boolean | |
3217 | elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) | |
3218 | { | |
3219 | struct elf32_tic6x_link_hash_table *htab; | |
3220 | bfd *dynobj; | |
3221 | asection *s; | |
3222 | bfd_boolean relocs; | |
3223 | bfd *ibfd; | |
3224 | ||
3225 | htab = elf32_tic6x_hash_table (info); | |
3226 | dynobj = htab->elf.dynobj; | |
3227 | if (dynobj == NULL) | |
3228 | abort (); | |
3229 | ||
3230 | if (htab->elf.dynamic_sections_created) | |
3231 | { | |
3232 | /* Set the contents of the .interp section to the interpreter. */ | |
9b8b325a | 3233 | if (bfd_link_executable (info) && !info->nointerp) |
ac145307 | 3234 | { |
3d4d4302 | 3235 | s = bfd_get_linker_section (dynobj, ".interp"); |
ac145307 BS |
3236 | if (s == NULL) |
3237 | abort (); | |
3238 | s->size = sizeof ELF_DYNAMIC_INTERPRETER; | |
3239 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; | |
3240 | } | |
3241 | } | |
3242 | ||
3243 | /* Set up .got offsets for local syms, and space for local dynamic | |
3244 | relocs. */ | |
c72f2fb2 | 3245 | for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
ac145307 BS |
3246 | { |
3247 | bfd_signed_vma *local_got; | |
3248 | bfd_signed_vma *end_local_got; | |
ac145307 BS |
3249 | bfd_size_type locsymcount; |
3250 | Elf_Internal_Shdr *symtab_hdr; | |
3251 | asection *srel; | |
3252 | ||
3253 | for (s = ibfd->sections; s != NULL; s = s->next) | |
3254 | { | |
3255 | struct elf_dyn_relocs *p; | |
3256 | ||
3257 | for (p = ((struct elf_dyn_relocs *) | |
3258 | elf_section_data (s)->local_dynrel); | |
3259 | p != NULL; | |
3260 | p = p->next) | |
3261 | { | |
3262 | if (!bfd_is_abs_section (p->sec) | |
3263 | && bfd_is_abs_section (p->sec->output_section)) | |
3264 | { | |
3265 | /* Input section has been discarded, either because | |
3266 | it is a copy of a linkonce section or due to | |
3267 | linker script /DISCARD/, so we'll be discarding | |
3268 | the relocs too. */ | |
3269 | } | |
3270 | else if (p->count != 0) | |
3271 | { | |
3272 | srel = elf_section_data (p->sec)->sreloc; | |
3273 | srel->size += p->count * sizeof (Elf32_External_Rela); | |
3274 | if ((p->sec->output_section->flags & SEC_READONLY) != 0) | |
3275 | info->flags |= DF_TEXTREL; | |
3276 | } | |
3277 | } | |
3278 | } | |
3279 | ||
3280 | local_got = elf_local_got_refcounts (ibfd); | |
3281 | if (!local_got) | |
3282 | continue; | |
3283 | ||
3284 | symtab_hdr = &elf_symtab_hdr (ibfd); | |
3285 | locsymcount = symtab_hdr->sh_info; | |
3286 | end_local_got = local_got + locsymcount; | |
3287 | s = htab->elf.sgot; | |
3288 | srel = htab->elf.srelgot; | |
544008aa | 3289 | for (; local_got < end_local_got; ++local_got) |
ac145307 BS |
3290 | { |
3291 | if (*local_got > 0) | |
3292 | { | |
3293 | *local_got = s->size; | |
3294 | s->size += 4; | |
3295 | ||
0e1862bb | 3296 | if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd)) |
ac145307 BS |
3297 | { |
3298 | srel->size += sizeof (Elf32_External_Rela); | |
3299 | } | |
3300 | } | |
3301 | else | |
3302 | *local_got = (bfd_vma) -1; | |
3303 | } | |
3304 | } | |
3305 | ||
3306 | /* Allocate global sym .plt and .got entries, and space for global | |
3307 | sym dynamic relocs. */ | |
3308 | elf_link_hash_traverse (&htab->elf, elf32_tic6x_allocate_dynrelocs, info); | |
3309 | ||
3310 | /* We now have determined the sizes of the various dynamic sections. | |
3311 | Allocate memory for them. */ | |
3312 | relocs = FALSE; | |
3313 | for (s = dynobj->sections; s != NULL; s = s->next) | |
3314 | { | |
3315 | bfd_boolean strip_section = TRUE; | |
3316 | ||
3317 | if ((s->flags & SEC_LINKER_CREATED) == 0) | |
3318 | continue; | |
3319 | ||
3320 | if (s == htab->dsbt) | |
3321 | s->size = 4 * htab->params.dsbt_size; | |
3322 | else if (s == htab->elf.splt | |
3323 | || s == htab->elf.sgot | |
3324 | || s == htab->elf.sgotplt | |
5474d94f AM |
3325 | || s == htab->elf.sdynbss |
3326 | || s == htab->elf.sdynrelro) | |
ac145307 BS |
3327 | { |
3328 | /* Strip this section if we don't need it; see the | |
3329 | comment below. */ | |
3330 | /* We'd like to strip these sections if they aren't needed, but if | |
3331 | we've exported dynamic symbols from them we must leave them. | |
3332 | It's too late to tell BFD to get rid of the symbols. */ | |
3333 | ||
3334 | if (htab->elf.hplt != NULL) | |
3335 | strip_section = FALSE; | |
3336 | ||
3337 | /* Round up the size of the PLT section to a multiple of 32. */ | |
3338 | if (s == htab->elf.splt && s->size > 0) | |
3339 | s->size = (s->size + 31) & ~(bfd_vma)31; | |
3340 | } | |
3341 | else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) | |
3342 | { | |
3343 | if (s->size != 0 | |
3344 | && s != htab->elf.srelplt) | |
3345 | relocs = TRUE; | |
3346 | ||
3347 | /* We use the reloc_count field as a counter if we need | |
3348 | to copy relocs into the output file. */ | |
3349 | s->reloc_count = 0; | |
3350 | } | |
3351 | else | |
3352 | { | |
3353 | /* It's not one of our sections, so don't allocate space. */ | |
3354 | continue; | |
3355 | } | |
3356 | ||
3357 | if (s->size == 0) | |
3358 | { | |
3359 | /* If we don't need this section, strip it from the | |
3360 | output file. This is mostly to handle .rel.bss and | |
3361 | .rel.plt. We must create both sections in | |
3362 | create_dynamic_sections, because they must be created | |
3363 | before the linker maps input sections to output | |
3364 | sections. The linker does that before | |
3365 | adjust_dynamic_symbol is called, and it is that | |
3366 | function which decides whether anything needs to go | |
3367 | into these sections. */ | |
3368 | if (strip_section) | |
3369 | s->flags |= SEC_EXCLUDE; | |
3370 | continue; | |
3371 | } | |
3372 | ||
3373 | if ((s->flags & SEC_HAS_CONTENTS) == 0) | |
3374 | continue; | |
3375 | ||
3376 | /* Allocate memory for the section contents. We use bfd_zalloc | |
3377 | here in case unused entries are not reclaimed before the | |
3378 | section's contents are written out. This should not happen, | |
3379 | but this way if it does, we get a R_C6000_NONE reloc instead | |
3380 | of garbage. */ | |
3381 | s->contents = bfd_zalloc (dynobj, s->size); | |
3382 | if (s->contents == NULL) | |
3383 | return FALSE; | |
3384 | } | |
3385 | ||
3386 | if (htab->elf.dynamic_sections_created) | |
3387 | { | |
3388 | /* Add some entries to the .dynamic section. We fill in the | |
3389 | values later, in elf32_tic6x_finish_dynamic_sections, but we | |
3390 | must add the entries now so that we get the correct size for | |
3391 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
3392 | dynamic linker and used by the debugger. */ | |
3393 | #define add_dynamic_entry(TAG, VAL) \ | |
3394 | _bfd_elf_add_dynamic_entry (info, TAG, VAL) | |
3395 | ||
0e1862bb | 3396 | if (bfd_link_executable (info)) |
ac145307 BS |
3397 | { |
3398 | if (!add_dynamic_entry (DT_DEBUG, 0)) | |
3399 | return FALSE; | |
3400 | } | |
3401 | ||
3402 | if (!add_dynamic_entry (DT_C6000_DSBT_BASE, 0) | |
3403 | || !add_dynamic_entry (DT_C6000_DSBT_SIZE, htab->params.dsbt_size) | |
3404 | || !add_dynamic_entry (DT_C6000_DSBT_INDEX, | |
3405 | htab->params.dsbt_index)) | |
3406 | return FALSE; | |
3407 | ||
3408 | if (htab->elf.splt->size != 0) | |
3409 | { | |
3410 | if (!add_dynamic_entry (DT_PLTGOT, 0) | |
3411 | || !add_dynamic_entry (DT_PLTRELSZ, 0) | |
3412 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | |
3413 | || !add_dynamic_entry (DT_JMPREL, 0)) | |
3414 | return FALSE; | |
3415 | } | |
3416 | ||
3417 | if (relocs) | |
3418 | { | |
3419 | if (!add_dynamic_entry (DT_RELA, 0) | |
3420 | || !add_dynamic_entry (DT_RELASZ, 0) | |
3421 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) | |
3422 | return FALSE; | |
3423 | ||
3424 | /* If any dynamic relocs apply to a read-only section, | |
3425 | then we need a DT_TEXTREL entry. */ | |
3426 | if ((info->flags & DF_TEXTREL) == 0) | |
63c1f59d | 3427 | elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); |
ac145307 BS |
3428 | |
3429 | if ((info->flags & DF_TEXTREL) != 0) | |
3430 | { | |
3431 | if (!add_dynamic_entry (DT_TEXTREL, 0)) | |
3432 | return FALSE; | |
3433 | } | |
3434 | } | |
3435 | } | |
3436 | #undef add_dynamic_entry | |
3437 | ||
3438 | return TRUE; | |
3439 | } | |
3440 | ||
3441 | /* This function is called after all the input files have been read, | |
3442 | and the input sections have been assigned to output sections. */ | |
3443 | ||
3444 | static bfd_boolean | |
3445 | elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) | |
3446 | { | |
0e1862bb | 3447 | if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info) |
04c3a755 NS |
3448 | && !bfd_elf_stack_segment_size (output_bfd, info, |
3449 | "__stacksize", DEFAULT_STACK_SIZE)) | |
3450 | return FALSE; | |
ac145307 BS |
3451 | |
3452 | return TRUE; | |
3453 | } | |
3454 | ||
3455 | static bfd_boolean | |
3456 | elf32_tic6x_finish_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | |
3457 | struct bfd_link_info *info) | |
3458 | { | |
3459 | struct elf32_tic6x_link_hash_table *htab; | |
3460 | bfd *dynobj; | |
3461 | asection *sdyn; | |
3462 | ||
3463 | htab = elf32_tic6x_hash_table (info); | |
3464 | dynobj = htab->elf.dynobj; | |
3d4d4302 | 3465 | sdyn = bfd_get_linker_section (dynobj, ".dynamic"); |
ac145307 BS |
3466 | |
3467 | if (elf_hash_table (info)->dynamic_sections_created) | |
3468 | { | |
3469 | Elf32_External_Dyn * dyncon; | |
3470 | Elf32_External_Dyn * dynconend; | |
3471 | ||
3472 | BFD_ASSERT (sdyn != NULL); | |
3473 | ||
3474 | dyncon = (Elf32_External_Dyn *) sdyn->contents; | |
3475 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); | |
3476 | ||
3477 | for (; dyncon < dynconend; dyncon++) | |
3478 | { | |
3479 | Elf_Internal_Dyn dyn; | |
3480 | asection *s; | |
3481 | ||
3482 | bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); | |
3483 | ||
3484 | switch (dyn.d_tag) | |
3485 | { | |
3486 | default: | |
3487 | break; | |
3488 | ||
3489 | case DT_C6000_DSBT_BASE: | |
3490 | s = htab->dsbt; | |
3491 | dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset); | |
3492 | break; | |
3493 | ||
3494 | case DT_PLTGOT: | |
3495 | s = htab->elf.sgotplt; | |
3496 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; | |
3497 | break; | |
3498 | ||
3499 | case DT_JMPREL: | |
3500 | s = htab->elf.srelplt; | |
3501 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; | |
3502 | break; | |
3503 | ||
3504 | case DT_PLTRELSZ: | |
3505 | s = htab->elf.srelplt; | |
3506 | dyn.d_un.d_val = s->size; | |
3507 | break; | |
3508 | } | |
3509 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
3510 | } | |
3511 | ||
3512 | /* Fill in the first entry in the procedure linkage table. */ | |
3513 | if (htab->elf.splt && htab->elf.splt->size > 0) | |
3514 | { | |
3515 | bfd_vma got_offs = (htab->elf.sgotplt->output_section->vma | |
3516 | + htab->elf.sgotplt->output_offset | |
3517 | - htab->dsbt->output_section->vma | |
3518 | - htab->dsbt->output_offset) / 4; | |
3519 | ||
3520 | /* ldw .D2T2 *+b14[$GOT(0)],b2 */ | |
3521 | bfd_put_32 (output_bfd, got_offs << 8 | 0x0100006e, | |
3522 | htab->elf.splt->contents); | |
3523 | /* ldw .D2T2 *+b14[$GOT(4)],b1 */ | |
3524 | bfd_put_32 (output_bfd, (got_offs + 1) << 8 | 0x0080006e, | |
3525 | htab->elf.splt->contents + 4); | |
3526 | /* nop 3 */ | |
3527 | bfd_put_32 (output_bfd, 0x00004000, | |
3528 | htab->elf.splt->contents + 8); | |
3529 | /* b .s2 b2 */ | |
3530 | bfd_put_32 (output_bfd, 0x00080362, | |
3531 | htab->elf.splt->contents + 12); | |
3532 | /* nop 5 */ | |
3533 | bfd_put_32 (output_bfd, 0x00008000, | |
3534 | htab->elf.splt->contents + 16); | |
3535 | ||
3536 | elf_section_data (htab->elf.splt->output_section) | |
3537 | ->this_hdr.sh_entsize = PLT_ENTRY_SIZE; | |
3538 | } | |
3539 | } | |
3540 | ||
3541 | return TRUE; | |
3542 | } | |
3543 | ||
3544 | /* Return address for Ith PLT stub in section PLT, for relocation REL | |
3545 | or (bfd_vma) -1 if it should not be included. */ | |
3546 | ||
3547 | static bfd_vma | |
3548 | elf32_tic6x_plt_sym_val (bfd_vma i, const asection *plt, | |
3549 | const arelent *rel ATTRIBUTE_UNUSED) | |
3550 | { | |
3551 | return plt->vma + (i + 1) * PLT_ENTRY_SIZE; | |
3552 | } | |
3553 | ||
3554 | static int | |
3555 | elf32_tic6x_obj_attrs_arg_type (int tag) | |
59e6276b | 3556 | { |
3cbd1c06 | 3557 | if (tag == Tag_ABI_compatibility) |
59e6276b | 3558 | return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL; |
87779176 JM |
3559 | else if (tag & 1) |
3560 | return ATTR_TYPE_FLAG_STR_VAL; | |
59e6276b | 3561 | else |
59e6276b JM |
3562 | return ATTR_TYPE_FLAG_INT_VAL; |
3563 | } | |
3564 | ||
87779176 JM |
3565 | static int |
3566 | elf32_tic6x_obj_attrs_order (int num) | |
3567 | { | |
3568 | if (num == LEAST_KNOWN_OBJ_ATTRIBUTE) | |
3569 | return Tag_ABI_conformance; | |
3570 | if ((num - 1) < Tag_ABI_conformance) | |
3571 | return num - 1; | |
3572 | return num; | |
3573 | } | |
3574 | ||
0547accf JM |
3575 | static bfd_boolean |
3576 | elf32_tic6x_obj_attrs_handle_unknown (bfd *abfd, int tag) | |
3577 | { | |
3578 | if ((tag & 127) < 64) | |
3579 | { | |
3580 | _bfd_error_handler | |
695344c0 | 3581 | /* xgettext:c-format */ |
871b3ab2 | 3582 | (_("%pB: error: unknown mandatory EABI object attribute %d"), |
0547accf JM |
3583 | abfd, tag); |
3584 | bfd_set_error (bfd_error_bad_value); | |
3585 | return FALSE; | |
3586 | } | |
3587 | else | |
3588 | { | |
3589 | _bfd_error_handler | |
695344c0 | 3590 | /* xgettext:c-format */ |
871b3ab2 | 3591 | (_("%pB: warning: unknown EABI object attribute %d"), |
0547accf JM |
3592 | abfd, tag); |
3593 | return TRUE; | |
3594 | } | |
3595 | } | |
3596 | ||
75fa6dc1 | 3597 | /* Merge the Tag_ISA attribute values ARCH1 and ARCH2 |
59e6276b JM |
3598 | and return the merged value. At present, all merges succeed, so no |
3599 | return value for errors is defined. */ | |
3600 | ||
3601 | int | |
3602 | elf32_tic6x_merge_arch_attributes (int arch1, int arch2) | |
3603 | { | |
3604 | int min_arch, max_arch; | |
3605 | ||
3606 | min_arch = (arch1 < arch2 ? arch1 : arch2); | |
3607 | max_arch = (arch1 > arch2 ? arch1 : arch2); | |
3608 | ||
3609 | /* In most cases, the numerically greatest value is the correct | |
3610 | merged value, but merging C64 and C67 results in C674X. */ | |
75fa6dc1 JM |
3611 | if ((min_arch == C6XABI_Tag_ISA_C67X |
3612 | || min_arch == C6XABI_Tag_ISA_C67XP) | |
3613 | && (max_arch == C6XABI_Tag_ISA_C64X | |
3614 | || max_arch == C6XABI_Tag_ISA_C64XP)) | |
3615 | return C6XABI_Tag_ISA_C674X; | |
59e6276b JM |
3616 | |
3617 | return max_arch; | |
3618 | } | |
3619 | ||
87779176 JM |
3620 | /* Convert a Tag_ABI_array_object_alignment or |
3621 | Tag_ABI_array_object_align_expected tag value TAG to a | |
3622 | corresponding alignment value; return the alignment, or -1 for an | |
3623 | unknown tag value. */ | |
3624 | ||
3625 | static int | |
3626 | elf32_tic6x_tag_to_array_alignment (int tag) | |
3627 | { | |
3628 | switch (tag) | |
3629 | { | |
3630 | case 0: | |
3631 | return 8; | |
3632 | ||
3633 | case 1: | |
3634 | return 4; | |
3635 | ||
3636 | case 2: | |
3637 | return 16; | |
3638 | ||
3639 | default: | |
3640 | return -1; | |
3641 | } | |
3642 | } | |
3643 | ||
3644 | /* Convert a Tag_ABI_array_object_alignment or | |
3645 | Tag_ABI_array_object_align_expected alignment ALIGN to a | |
3646 | corresponding tag value; return the tag value. */ | |
3647 | ||
3648 | static int | |
3649 | elf32_tic6x_array_alignment_to_tag (int align) | |
3650 | { | |
3651 | switch (align) | |
3652 | { | |
3653 | case 8: | |
3654 | return 0; | |
3655 | ||
3656 | case 4: | |
3657 | return 1; | |
3658 | ||
3659 | case 16: | |
3660 | return 2; | |
3661 | ||
3662 | default: | |
3663 | abort (); | |
3664 | } | |
3665 | } | |
3666 | ||
59e6276b JM |
3667 | /* Merge attributes from IBFD and OBFD, returning TRUE if the merge |
3668 | succeeded, FALSE otherwise. */ | |
3669 | ||
3670 | static bfd_boolean | |
50e03d47 | 3671 | elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) |
59e6276b | 3672 | { |
50e03d47 | 3673 | bfd *obfd = info->output_bfd; |
87779176 | 3674 | bfd_boolean result = TRUE; |
59e6276b JM |
3675 | obj_attribute *in_attr; |
3676 | obj_attribute *out_attr; | |
87779176 JM |
3677 | int i; |
3678 | int array_align_in, array_align_out, array_expect_in, array_expect_out; | |
59e6276b JM |
3679 | |
3680 | if (!elf_known_obj_attributes_proc (obfd)[0].i) | |
3681 | { | |
3682 | /* This is the first object. Copy the attributes. */ | |
3683 | _bfd_elf_copy_obj_attributes (ibfd, obfd); | |
3684 | ||
3685 | out_attr = elf_known_obj_attributes_proc (obfd); | |
3686 | ||
3687 | /* Use the Tag_null value to indicate the attributes have been | |
3688 | initialized. */ | |
3689 | out_attr[0].i = 1; | |
3690 | ||
3691 | return TRUE; | |
3692 | } | |
3693 | ||
3694 | in_attr = elf_known_obj_attributes_proc (ibfd); | |
3695 | out_attr = elf_known_obj_attributes_proc (obfd); | |
3696 | ||
3697 | /* No specification yet for handling of unknown attributes, so just | |
3698 | ignore them and handle known ones. */ | |
59e6276b | 3699 | |
87779176 JM |
3700 | if (out_attr[Tag_ABI_stack_align_preserved].i |
3701 | < in_attr[Tag_ABI_stack_align_needed].i) | |
3702 | { | |
3703 | _bfd_error_handler | |
695344c0 | 3704 | /* xgettext:c-format */ |
871b3ab2 | 3705 | (_("error: %pB requires more stack alignment than %pB preserves"), |
87779176 JM |
3706 | ibfd, obfd); |
3707 | result = FALSE; | |
3708 | } | |
3709 | if (in_attr[Tag_ABI_stack_align_preserved].i | |
3710 | < out_attr[Tag_ABI_stack_align_needed].i) | |
3711 | { | |
3712 | _bfd_error_handler | |
695344c0 | 3713 | /* xgettext:c-format */ |
871b3ab2 | 3714 | (_("error: %pB requires more stack alignment than %pB preserves"), |
87779176 JM |
3715 | obfd, ibfd); |
3716 | result = FALSE; | |
3717 | } | |
3718 | ||
3719 | array_align_in = elf32_tic6x_tag_to_array_alignment | |
3720 | (in_attr[Tag_ABI_array_object_alignment].i); | |
3721 | if (array_align_in == -1) | |
3722 | { | |
3723 | _bfd_error_handler | |
871b3ab2 | 3724 | (_("error: unknown Tag_ABI_array_object_alignment value in %pB"), |
87779176 JM |
3725 | ibfd); |
3726 | result = FALSE; | |
3727 | } | |
3728 | array_align_out = elf32_tic6x_tag_to_array_alignment | |
3729 | (out_attr[Tag_ABI_array_object_alignment].i); | |
3730 | if (array_align_out == -1) | |
3731 | { | |
3732 | _bfd_error_handler | |
871b3ab2 | 3733 | (_("error: unknown Tag_ABI_array_object_alignment value in %pB"), |
87779176 JM |
3734 | obfd); |
3735 | result = FALSE; | |
3736 | } | |
3737 | array_expect_in = elf32_tic6x_tag_to_array_alignment | |
3738 | (in_attr[Tag_ABI_array_object_align_expected].i); | |
3739 | if (array_expect_in == -1) | |
3740 | { | |
3741 | _bfd_error_handler | |
871b3ab2 | 3742 | (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"), |
87779176 JM |
3743 | ibfd); |
3744 | result = FALSE; | |
3745 | } | |
3746 | array_expect_out = elf32_tic6x_tag_to_array_alignment | |
3747 | (out_attr[Tag_ABI_array_object_align_expected].i); | |
3748 | if (array_expect_out == -1) | |
3749 | { | |
3750 | _bfd_error_handler | |
871b3ab2 | 3751 | (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"), |
87779176 JM |
3752 | obfd); |
3753 | result = FALSE; | |
3754 | } | |
3755 | ||
3756 | if (array_align_out < array_expect_in) | |
3757 | { | |
3758 | _bfd_error_handler | |
695344c0 | 3759 | /* xgettext:c-format */ |
871b3ab2 | 3760 | (_("error: %pB requires more array alignment than %pB preserves"), |
87779176 JM |
3761 | ibfd, obfd); |
3762 | result = FALSE; | |
3763 | } | |
3764 | if (array_align_in < array_expect_out) | |
b5593623 JM |
3765 | { |
3766 | _bfd_error_handler | |
695344c0 | 3767 | /* xgettext:c-format */ |
871b3ab2 | 3768 | (_("error: %pB requires more array alignment than %pB preserves"), |
b5593623 | 3769 | obfd, ibfd); |
87779176 | 3770 | result = FALSE; |
b5593623 | 3771 | } |
87779176 JM |
3772 | |
3773 | for (i = LEAST_KNOWN_OBJ_ATTRIBUTE; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++) | |
3774 | { | |
3775 | switch (i) | |
3776 | { | |
3777 | case Tag_ISA: | |
3778 | out_attr[i].i = elf32_tic6x_merge_arch_attributes (in_attr[i].i, | |
3779 | out_attr[i].i); | |
3780 | break; | |
3781 | ||
3782 | case Tag_ABI_wchar_t: | |
3783 | if (out_attr[i].i == 0) | |
3784 | out_attr[i].i = in_attr[i].i; | |
3785 | if (out_attr[i].i != 0 | |
3786 | && in_attr[i].i != 0 | |
3787 | && out_attr[i].i != in_attr[i].i) | |
3788 | { | |
3789 | _bfd_error_handler | |
695344c0 | 3790 | /* xgettext:c-format */ |
871b3ab2 | 3791 | (_("warning: %pB and %pB differ in wchar_t size"), obfd, ibfd); |
87779176 JM |
3792 | } |
3793 | break; | |
3794 | ||
3795 | case Tag_ABI_stack_align_needed: | |
3796 | if (out_attr[i].i < in_attr[i].i) | |
3797 | out_attr[i].i = in_attr[i].i; | |
3798 | break; | |
3799 | ||
3800 | case Tag_ABI_stack_align_preserved: | |
3801 | if (out_attr[i].i > in_attr[i].i) | |
3802 | out_attr[i].i = in_attr[i].i; | |
3803 | break; | |
3804 | ||
3805 | case Tag_ABI_DSBT: | |
3806 | if (out_attr[i].i != in_attr[i].i) | |
3807 | { | |
3808 | _bfd_error_handler | |
695344c0 | 3809 | /* xgettext:c-format */ |
871b3ab2 | 3810 | (_("warning: %pB and %pB differ in whether code is " |
87779176 JM |
3811 | "compiled for DSBT"), |
3812 | obfd, ibfd); | |
3813 | } | |
3814 | break; | |
3815 | ||
87779176 | 3816 | case Tag_ABI_PIC: |
c6a8f6e0 BS |
3817 | case Tag_ABI_PID: |
3818 | if (out_attr[i].i > in_attr[i].i) | |
3819 | out_attr[i].i = in_attr[i].i; | |
87779176 JM |
3820 | break; |
3821 | ||
3822 | case Tag_ABI_array_object_alignment: | |
3823 | if (array_align_out != -1 | |
3824 | && array_align_in != -1 | |
3825 | && array_align_out > array_align_in) | |
3826 | out_attr[i].i | |
3827 | = elf32_tic6x_array_alignment_to_tag (array_align_in); | |
3828 | break; | |
3829 | ||
3830 | case Tag_ABI_array_object_align_expected: | |
3831 | if (array_expect_out != -1 | |
3832 | && array_expect_in != -1 | |
3833 | && array_expect_out < array_expect_in) | |
3834 | out_attr[i].i | |
3835 | = elf32_tic6x_array_alignment_to_tag (array_expect_in); | |
3836 | break; | |
3837 | ||
3838 | case Tag_ABI_conformance: | |
3839 | /* Merging for this attribute is not specified. As on ARM, | |
3840 | treat a missing attribute as no claim to conform and only | |
3841 | merge identical values. */ | |
3842 | if (out_attr[i].s == NULL | |
3843 | || in_attr[i].s == NULL | |
3844 | || strcmp (out_attr[i].s, | |
3845 | in_attr[i].s) != 0) | |
3846 | out_attr[i].s = NULL; | |
3847 | break; | |
3848 | ||
0547accf JM |
3849 | case Tag_ABI_compatibility: |
3850 | /* Merged in _bfd_elf_merge_object_attributes. */ | |
3851 | break; | |
3852 | ||
87779176 | 3853 | default: |
0547accf JM |
3854 | result |
3855 | = result && _bfd_elf_merge_unknown_attribute_low (ibfd, obfd, i); | |
87779176 JM |
3856 | break; |
3857 | } | |
3858 | ||
3859 | if (in_attr[i].type && !out_attr[i].type) | |
3860 | out_attr[i].type = in_attr[i].type; | |
3861 | } | |
3862 | ||
3cbd1c06 | 3863 | /* Merge Tag_ABI_compatibility attributes and any common GNU ones. */ |
50e03d47 | 3864 | if (!_bfd_elf_merge_object_attributes (ibfd, info)) |
3cbd1c06 | 3865 | return FALSE; |
59e6276b | 3866 | |
0547accf JM |
3867 | result &= _bfd_elf_merge_unknown_attribute_list (ibfd, obfd); |
3868 | ||
87779176 | 3869 | return result; |
59e6276b JM |
3870 | } |
3871 | ||
3872 | static bfd_boolean | |
50e03d47 | 3873 | elf32_tic6x_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) |
59e6276b | 3874 | { |
50e03d47 | 3875 | if (!_bfd_generic_verify_endian_match (ibfd, info)) |
59e6276b JM |
3876 | return FALSE; |
3877 | ||
50e03d47 | 3878 | if (! is_tic6x_elf (ibfd) || ! is_tic6x_elf (info->output_bfd)) |
b781d74f JM |
3879 | return TRUE; |
3880 | ||
50e03d47 | 3881 | if (!elf32_tic6x_merge_attributes (ibfd, info)) |
59e6276b JM |
3882 | return FALSE; |
3883 | ||
3884 | return TRUE; | |
3885 | } | |
3886 | ||
fbd9ad90 PB |
3887 | /* Add a new unwind edit to the list described by HEAD, TAIL. If TINDEX is zero, |
3888 | adds the edit to the start of the list. (The list must be built in order of | |
3889 | ascending TINDEX: the function's callers are primarily responsible for | |
3890 | maintaining that condition). */ | |
3891 | ||
3892 | static void | |
3893 | elf32_tic6x_add_unwind_table_edit (tic6x_unwind_table_edit **head, | |
3894 | tic6x_unwind_table_edit **tail, | |
3895 | tic6x_unwind_edit_type type, | |
3896 | asection *linked_section, | |
3897 | unsigned int tindex) | |
3898 | { | |
3899 | tic6x_unwind_table_edit *new_edit = (tic6x_unwind_table_edit *) | |
3900 | xmalloc (sizeof (tic6x_unwind_table_edit)); | |
68ffbac6 | 3901 | |
fbd9ad90 PB |
3902 | new_edit->type = type; |
3903 | new_edit->linked_section = linked_section; | |
3904 | new_edit->index = tindex; | |
68ffbac6 | 3905 | |
fbd9ad90 PB |
3906 | if (tindex > 0) |
3907 | { | |
3908 | new_edit->next = NULL; | |
3909 | ||
3910 | if (*tail) | |
3911 | (*tail)->next = new_edit; | |
3912 | ||
3913 | (*tail) = new_edit; | |
3914 | ||
3915 | if (!*head) | |
3916 | (*head) = new_edit; | |
3917 | } | |
3918 | else | |
3919 | { | |
3920 | new_edit->next = *head; | |
3921 | ||
3922 | if (!*tail) | |
3923 | *tail = new_edit; | |
3924 | ||
3925 | *head = new_edit; | |
3926 | } | |
3927 | } | |
3928 | ||
3929 | static _tic6x_elf_section_data * | |
3930 | get_tic6x_elf_section_data (asection * sec) | |
3931 | { | |
3932 | if (sec && sec->owner && is_tic6x_elf (sec->owner)) | |
3933 | return elf32_tic6x_section_data (sec); | |
3934 | else | |
3935 | return NULL; | |
3936 | } | |
3937 | ||
3938 | ||
3939 | /* Increase the size of EXIDX_SEC by ADJUST bytes. ADJUST must be negative. */ | |
3940 | static void | |
3941 | elf32_tic6x_adjust_exidx_size (asection *exidx_sec, int adjust) | |
3942 | { | |
3943 | asection *out_sec; | |
3944 | ||
3945 | if (!exidx_sec->rawsize) | |
3946 | exidx_sec->rawsize = exidx_sec->size; | |
3947 | ||
3948 | bfd_set_section_size (exidx_sec->owner, exidx_sec, exidx_sec->size + adjust); | |
3949 | out_sec = exidx_sec->output_section; | |
3950 | /* Adjust size of output section. */ | |
3951 | bfd_set_section_size (out_sec->owner, out_sec, out_sec->size +adjust); | |
3952 | } | |
3953 | ||
3954 | /* Insert an EXIDX_CANTUNWIND marker at the end of a section. */ | |
3955 | static void | |
3956 | elf32_tic6x_insert_cantunwind_after (asection *text_sec, asection *exidx_sec) | |
3957 | { | |
3958 | struct _tic6x_elf_section_data *exidx_data; | |
3959 | ||
3960 | exidx_data = get_tic6x_elf_section_data (exidx_sec); | |
3961 | elf32_tic6x_add_unwind_table_edit ( | |
3962 | &exidx_data->u.exidx.unwind_edit_list, | |
3963 | &exidx_data->u.exidx.unwind_edit_tail, | |
3964 | INSERT_EXIDX_CANTUNWIND_AT_END, text_sec, UINT_MAX); | |
3965 | ||
3966 | elf32_tic6x_adjust_exidx_size (exidx_sec, 8); | |
3967 | } | |
3968 | ||
3969 | /* Scan .cx6abi.exidx tables, and create a list describing edits which | |
3970 | should be made to those tables, such that: | |
68ffbac6 | 3971 | |
fbd9ad90 PB |
3972 | 1. Regions without unwind data are marked with EXIDX_CANTUNWIND entries. |
3973 | 2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind | |
07d6d2b8 | 3974 | codes which have been inlined into the index). |
fbd9ad90 PB |
3975 | |
3976 | If MERGE_EXIDX_ENTRIES is false, duplicate entries are not merged. | |
3977 | ||
3978 | The edits are applied when the tables are written | |
3979 | (in elf32_tic6x_write_section). | |
3980 | */ | |
3981 | ||
3982 | bfd_boolean | |
3983 | elf32_tic6x_fix_exidx_coverage (asection **text_section_order, | |
3984 | unsigned int num_text_sections, | |
3985 | struct bfd_link_info *info, | |
3986 | bfd_boolean merge_exidx_entries) | |
3987 | { | |
3988 | bfd *inp; | |
3989 | unsigned int last_second_word = 0, i; | |
3990 | asection *last_exidx_sec = NULL; | |
3991 | asection *last_text_sec = NULL; | |
3992 | int last_unwind_type = -1; | |
3993 | ||
3994 | /* Walk over all EXIDX sections, and create backlinks from the corrsponding | |
3995 | text sections. */ | |
c72f2fb2 | 3996 | for (inp = info->input_bfds; inp != NULL; inp = inp->link.next) |
fbd9ad90 PB |
3997 | { |
3998 | asection *sec; | |
68ffbac6 | 3999 | |
fbd9ad90 | 4000 | for (sec = inp->sections; sec != NULL; sec = sec->next) |
07d6d2b8 | 4001 | { |
fbd9ad90 PB |
4002 | struct bfd_elf_section_data *elf_sec = elf_section_data (sec); |
4003 | Elf_Internal_Shdr *hdr = &elf_sec->this_hdr; | |
68ffbac6 | 4004 | |
fbd9ad90 PB |
4005 | if (!hdr || hdr->sh_type != SHT_C6000_UNWIND) |
4006 | continue; | |
68ffbac6 | 4007 | |
fbd9ad90 PB |
4008 | if (elf_sec->linked_to) |
4009 | { | |
4010 | Elf_Internal_Shdr *linked_hdr | |
07d6d2b8 | 4011 | = &elf_section_data (elf_sec->linked_to)->this_hdr; |
fbd9ad90 | 4012 | struct _tic6x_elf_section_data *linked_sec_tic6x_data |
07d6d2b8 | 4013 | = get_tic6x_elf_section_data (linked_hdr->bfd_section); |
fbd9ad90 PB |
4014 | |
4015 | if (linked_sec_tic6x_data == NULL) | |
07d6d2b8 | 4016 | continue; |
fbd9ad90 PB |
4017 | |
4018 | /* Link this .c6xabi.exidx section back from the | |
4019 | text section it describes. */ | |
4020 | linked_sec_tic6x_data->u.text.tic6x_exidx_sec = sec; | |
4021 | } | |
4022 | } | |
4023 | } | |
4024 | ||
4025 | /* Walk all text sections in order of increasing VMA. Eilminate duplicate | |
4026 | index table entries (EXIDX_CANTUNWIND and inlined unwind opcodes), | |
4027 | and add EXIDX_CANTUNWIND entries for sections with no unwind table data. */ | |
4028 | ||
4029 | for (i = 0; i < num_text_sections; i++) | |
4030 | { | |
4031 | asection *sec = text_section_order[i]; | |
4032 | asection *exidx_sec; | |
4033 | struct _tic6x_elf_section_data *tic6x_data | |
07d6d2b8 | 4034 | = get_tic6x_elf_section_data (sec); |
fbd9ad90 PB |
4035 | struct _tic6x_elf_section_data *exidx_data; |
4036 | bfd_byte *contents = NULL; | |
4037 | int deleted_exidx_bytes = 0; | |
4038 | bfd_vma j; | |
4039 | tic6x_unwind_table_edit *unwind_edit_head = NULL; | |
4040 | tic6x_unwind_table_edit *unwind_edit_tail = NULL; | |
4041 | Elf_Internal_Shdr *hdr; | |
4042 | bfd *ibfd; | |
4043 | ||
4044 | if (tic6x_data == NULL) | |
07d6d2b8 | 4045 | continue; |
fbd9ad90 PB |
4046 | |
4047 | exidx_sec = tic6x_data->u.text.tic6x_exidx_sec; | |
4048 | if (exidx_sec == NULL) | |
4049 | { | |
4050 | /* Section has no unwind data. */ | |
4051 | if (last_unwind_type == 0 || !last_exidx_sec) | |
4052 | continue; | |
4053 | ||
4054 | /* Ignore zero sized sections. */ | |
4055 | if (sec->size == 0) | |
4056 | continue; | |
4057 | ||
4058 | elf32_tic6x_insert_cantunwind_after (last_text_sec, last_exidx_sec); | |
4059 | last_unwind_type = 0; | |
4060 | continue; | |
4061 | } | |
4062 | ||
4063 | /* Skip /DISCARD/ sections. */ | |
4064 | if (bfd_is_abs_section (exidx_sec->output_section)) | |
4065 | continue; | |
4066 | ||
4067 | hdr = &elf_section_data (exidx_sec)->this_hdr; | |
4068 | if (hdr->sh_type != SHT_C6000_UNWIND) | |
07d6d2b8 | 4069 | continue; |
68ffbac6 | 4070 | |
fbd9ad90 PB |
4071 | exidx_data = get_tic6x_elf_section_data (exidx_sec); |
4072 | if (exidx_data == NULL) | |
07d6d2b8 | 4073 | continue; |
68ffbac6 | 4074 | |
fbd9ad90 | 4075 | ibfd = exidx_sec->owner; |
68ffbac6 | 4076 | |
fbd9ad90 PB |
4077 | if (hdr->contents != NULL) |
4078 | contents = hdr->contents; | |
4079 | else if (! bfd_malloc_and_get_section (ibfd, exidx_sec, &contents)) | |
4080 | /* An error? */ | |
4081 | continue; | |
4082 | ||
4083 | for (j = 0; j < hdr->sh_size; j += 8) | |
4084 | { | |
4085 | unsigned int second_word = bfd_get_32 (ibfd, contents + j + 4); | |
4086 | int unwind_type; | |
4087 | int elide = 0; | |
4088 | ||
4089 | /* An EXIDX_CANTUNWIND entry. */ | |
4090 | if (second_word == 1) | |
4091 | { | |
4092 | if (last_unwind_type == 0) | |
4093 | elide = 1; | |
4094 | unwind_type = 0; | |
4095 | } | |
4096 | /* Inlined unwinding data. Merge if equal to previous. */ | |
4097 | else if ((second_word & 0x80000000) != 0) | |
4098 | { | |
4099 | if (merge_exidx_entries | |
4100 | && last_second_word == second_word | |
4101 | && last_unwind_type == 1) | |
4102 | elide = 1; | |
4103 | unwind_type = 1; | |
4104 | last_second_word = second_word; | |
4105 | } | |
4106 | /* Normal table entry. In theory we could merge these too, | |
4107 | but duplicate entries are likely to be much less common. */ | |
4108 | else | |
4109 | unwind_type = 2; | |
4110 | ||
4111 | if (elide) | |
4112 | { | |
4113 | elf32_tic6x_add_unwind_table_edit (&unwind_edit_head, | |
4114 | &unwind_edit_tail, DELETE_EXIDX_ENTRY, NULL, j / 8); | |
4115 | ||
4116 | deleted_exidx_bytes += 8; | |
4117 | } | |
4118 | ||
4119 | last_unwind_type = unwind_type; | |
4120 | } | |
4121 | ||
4122 | /* Free contents if we allocated it ourselves. */ | |
4123 | if (contents != hdr->contents) | |
07d6d2b8 | 4124 | free (contents); |
fbd9ad90 PB |
4125 | |
4126 | /* Record edits to be applied later (in elf32_tic6x_write_section). */ | |
4127 | exidx_data->u.exidx.unwind_edit_list = unwind_edit_head; | |
4128 | exidx_data->u.exidx.unwind_edit_tail = unwind_edit_tail; | |
68ffbac6 | 4129 | |
fbd9ad90 PB |
4130 | if (deleted_exidx_bytes > 0) |
4131 | elf32_tic6x_adjust_exidx_size (exidx_sec, -deleted_exidx_bytes); | |
4132 | ||
4133 | last_exidx_sec = exidx_sec; | |
4134 | last_text_sec = sec; | |
4135 | } | |
4136 | ||
4137 | /* Add terminating CANTUNWIND entry. */ | |
4138 | if (last_exidx_sec && last_unwind_type != 0) | |
4139 | elf32_tic6x_insert_cantunwind_after (last_text_sec, last_exidx_sec); | |
4140 | ||
4141 | return TRUE; | |
4142 | } | |
4143 | ||
4144 | /* Add ADDEND to lower 31 bits of VAL, leaving other bits unmodified. */ | |
4145 | ||
4146 | static unsigned long | |
4147 | elf32_tic6x_add_low31 (unsigned long val, bfd_vma addend) | |
4148 | { | |
4149 | return (val & ~0x7ffffffful) | ((val + addend) & 0x7ffffffful); | |
4150 | } | |
4151 | ||
4152 | /* Copy an .c6xabi.exidx table entry, adding OFFSET to (applied) PREL31 | |
4153 | relocations. OFFSET is in bytes, and will be scaled before encoding. */ | |
4154 | ||
4155 | ||
4156 | static void | |
4157 | elf32_tic6x_copy_exidx_entry (bfd *output_bfd, bfd_byte *to, bfd_byte *from, | |
4158 | bfd_vma offset) | |
4159 | { | |
4160 | unsigned long first_word = bfd_get_32 (output_bfd, from); | |
4161 | unsigned long second_word = bfd_get_32 (output_bfd, from + 4); | |
4162 | ||
4163 | offset >>= 1; | |
4164 | /* High bit of first word is supposed to be zero. */ | |
4165 | if ((first_word & 0x80000000ul) == 0) | |
4166 | first_word = elf32_tic6x_add_low31 (first_word, offset); | |
68ffbac6 | 4167 | |
fbd9ad90 PB |
4168 | /* If the high bit of the first word is clear, and the bit pattern is not 0x1 |
4169 | (EXIDX_CANTUNWIND), this is an offset to an .c6xabi.extab entry. */ | |
4170 | if ((second_word != 0x1) && ((second_word & 0x80000000ul) == 0)) | |
4171 | second_word = elf32_tic6x_add_low31 (second_word, offset); | |
68ffbac6 | 4172 | |
fbd9ad90 PB |
4173 | bfd_put_32 (output_bfd, first_word, to); |
4174 | bfd_put_32 (output_bfd, second_word, to + 4); | |
4175 | } | |
4176 | ||
4177 | /* Do the actual mangling of exception index tables. */ | |
4178 | ||
4179 | static bfd_boolean | |
4180 | elf32_tic6x_write_section (bfd *output_bfd, | |
4181 | struct bfd_link_info *link_info, | |
4182 | asection *sec, | |
4183 | bfd_byte *contents) | |
4184 | { | |
4185 | _tic6x_elf_section_data *tic6x_data; | |
4186 | struct elf32_tic6x_link_hash_table *globals | |
4187 | = elf32_tic6x_hash_table (link_info); | |
4188 | bfd_vma offset = sec->output_section->vma + sec->output_offset; | |
4189 | ||
4190 | if (globals == NULL) | |
4191 | return FALSE; | |
4192 | ||
4193 | /* If this section has not been allocated an _tic6x_elf_section_data | |
4194 | structure then we cannot record anything. */ | |
4195 | tic6x_data = get_tic6x_elf_section_data (sec); | |
4196 | if (tic6x_data == NULL) | |
4197 | return FALSE; | |
4198 | ||
4199 | if (tic6x_data->elf.this_hdr.sh_type != SHT_C6000_UNWIND) | |
4200 | return FALSE; | |
4201 | ||
4202 | tic6x_unwind_table_edit *edit_node | |
4203 | = tic6x_data->u.exidx.unwind_edit_list; | |
4204 | /* Now, sec->size is the size of the section we will write. The original | |
4205 | size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND | |
4206 | markers) was sec->rawsize. (This isn't the case if we perform no | |
4207 | edits, then rawsize will be zero and we should use size). */ | |
4208 | bfd_byte *edited_contents = (bfd_byte *) bfd_malloc (sec->size); | |
4209 | unsigned int input_size = sec->rawsize ? sec->rawsize : sec->size; | |
4210 | unsigned int in_index, out_index; | |
4211 | bfd_vma add_to_offsets = 0; | |
4212 | ||
4213 | for (in_index = 0, out_index = 0; in_index * 8 < input_size || edit_node;) | |
4214 | { | |
4215 | if (edit_node) | |
4216 | { | |
4217 | unsigned int edit_index = edit_node->index; | |
68ffbac6 | 4218 | |
fbd9ad90 PB |
4219 | if (in_index < edit_index && in_index * 8 < input_size) |
4220 | { | |
4221 | elf32_tic6x_copy_exidx_entry (output_bfd, | |
4222 | edited_contents + out_index * 8, | |
4223 | contents + in_index * 8, add_to_offsets); | |
4224 | out_index++; | |
4225 | in_index++; | |
4226 | } | |
4227 | else if (in_index == edit_index | |
4228 | || (in_index * 8 >= input_size | |
4229 | && edit_index == UINT_MAX)) | |
4230 | { | |
4231 | switch (edit_node->type) | |
4232 | { | |
4233 | case DELETE_EXIDX_ENTRY: | |
4234 | in_index++; | |
4235 | add_to_offsets += 8; | |
4236 | break; | |
68ffbac6 | 4237 | |
fbd9ad90 PB |
4238 | case INSERT_EXIDX_CANTUNWIND_AT_END: |
4239 | { | |
4240 | asection *text_sec = edit_node->linked_section; | |
4241 | bfd_vma text_offset = text_sec->output_section->vma | |
4242 | + text_sec->output_offset | |
4243 | + text_sec->size; | |
4244 | bfd_vma exidx_offset = offset + out_index * 8; | |
4245 | unsigned long prel31_offset; | |
4246 | ||
4247 | /* Note: this is meant to be equivalent to an | |
4248 | R_C6000_PREL31 relocation. These synthetic | |
4249 | EXIDX_CANTUNWIND markers are not relocated by the | |
4250 | usual BFD method. */ | |
4251 | prel31_offset = ((text_offset - exidx_offset) >> 1) | |
4252 | & 0x7ffffffful; | |
4253 | ||
4254 | /* First address we can't unwind. */ | |
4255 | bfd_put_32 (output_bfd, prel31_offset, | |
4256 | &edited_contents[out_index * 8]); | |
4257 | ||
4258 | /* Code for EXIDX_CANTUNWIND. */ | |
4259 | bfd_put_32 (output_bfd, 0x1, | |
4260 | &edited_contents[out_index * 8 + 4]); | |
4261 | ||
4262 | out_index++; | |
4263 | add_to_offsets -= 8; | |
4264 | } | |
4265 | break; | |
4266 | } | |
68ffbac6 | 4267 | |
fbd9ad90 PB |
4268 | edit_node = edit_node->next; |
4269 | } | |
4270 | } | |
4271 | else | |
4272 | { | |
4273 | /* No more edits, copy remaining entries verbatim. */ | |
4274 | elf32_tic6x_copy_exidx_entry (output_bfd, | |
4275 | edited_contents + out_index * 8, | |
4276 | contents + in_index * 8, add_to_offsets); | |
4277 | out_index++; | |
4278 | in_index++; | |
4279 | } | |
4280 | } | |
4281 | ||
4282 | if (!(sec->flags & SEC_EXCLUDE) && !(sec->flags & SEC_NEVER_LOAD)) | |
4283 | bfd_set_section_contents (output_bfd, sec->output_section, | |
4284 | edited_contents, | |
4285 | (file_ptr) sec->output_offset, sec->size); | |
4286 | ||
4287 | return TRUE; | |
4288 | } | |
4289 | ||
6d00b590 | 4290 | #define TARGET_LITTLE_SYM tic6x_elf32_le_vec |
40b36596 | 4291 | #define TARGET_LITTLE_NAME "elf32-tic6x-le" |
6d00b590 | 4292 | #define TARGET_BIG_SYM tic6x_elf32_be_vec |
40b36596 JM |
4293 | #define TARGET_BIG_NAME "elf32-tic6x-be" |
4294 | #define ELF_ARCH bfd_arch_tic6x | |
ae95ffa6 | 4295 | #define ELF_TARGET_ID TIC6X_ELF_DATA |
40b36596 | 4296 | #define ELF_MACHINE_CODE EM_TI_C6000 |
ac145307 | 4297 | #define ELF_MAXPAGESIZE 0x1000 |
40b36596 JM |
4298 | #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup |
4299 | #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup | |
59e6276b | 4300 | #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data |
41820509 | 4301 | #define bfd_elf32_mkobject elf32_tic6x_mkobject |
ac145307 | 4302 | #define bfd_elf32_bfd_link_hash_table_create elf32_tic6x_link_hash_table_create |
41820509 | 4303 | #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook |
04c3a755 | 4304 | #define elf_backend_stack_align 8 |
40b36596 JM |
4305 | #define elf_backend_can_gc_sections 1 |
4306 | #define elf_backend_default_use_rela_p 1 | |
4307 | #define elf_backend_may_use_rel_p 1 | |
4308 | #define elf_backend_may_use_rela_p 1 | |
59e6276b | 4309 | #define elf_backend_obj_attrs_arg_type elf32_tic6x_obj_attrs_arg_type |
0547accf | 4310 | #define elf_backend_obj_attrs_handle_unknown elf32_tic6x_obj_attrs_handle_unknown |
87779176 | 4311 | #define elf_backend_obj_attrs_order elf32_tic6x_obj_attrs_order |
75fa6dc1 | 4312 | #define elf_backend_obj_attrs_section ".c6xabi.attributes" |
59e6276b JM |
4313 | #define elf_backend_obj_attrs_section_type SHT_C6000_ATTRIBUTES |
4314 | #define elf_backend_obj_attrs_vendor "c6xabi" | |
ac145307 BS |
4315 | #define elf_backend_can_refcount 1 |
4316 | #define elf_backend_want_got_plt 1 | |
4317 | #define elf_backend_want_dynbss 1 | |
5474d94f | 4318 | #define elf_backend_want_dynrelro 1 |
ac145307 | 4319 | #define elf_backend_plt_readonly 1 |
40b36596 | 4320 | #define elf_backend_rela_normal 1 |
ac145307 | 4321 | #define elf_backend_got_header_size 8 |
1bce6bd8 | 4322 | #define elf_backend_fake_sections elf32_tic6x_fake_sections |
9cf0e282 | 4323 | #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections |
ac145307 BS |
4324 | #define elf_backend_create_dynamic_sections \ |
4325 | elf32_tic6x_create_dynamic_sections | |
4326 | #define elf_backend_adjust_dynamic_symbol \ | |
4327 | elf32_tic6x_adjust_dynamic_symbol | |
07d6d2b8 | 4328 | #define elf_backend_check_relocs elf32_tic6x_check_relocs |
ac145307 BS |
4329 | #define elf_backend_add_symbol_hook elf32_tic6x_add_symbol_hook |
4330 | #define elf_backend_symbol_processing elf32_tic6x_symbol_processing | |
4331 | #define elf_backend_link_output_symbol_hook \ | |
4332 | elf32_tic6x_link_output_symbol_hook | |
4333 | #define elf_backend_section_from_bfd_section \ | |
4334 | elf32_tic6x_section_from_bfd_section | |
40b36596 | 4335 | #define elf_backend_relocate_section elf32_tic6x_relocate_section |
2a616379 | 4336 | #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible |
ac145307 BS |
4337 | #define elf_backend_finish_dynamic_symbol \ |
4338 | elf32_tic6x_finish_dynamic_symbol | |
4339 | #define elf_backend_always_size_sections \ | |
4340 | elf32_tic6x_always_size_sections | |
4341 | #define elf_backend_size_dynamic_sections \ | |
4342 | elf32_tic6x_size_dynamic_sections | |
4343 | #define elf_backend_finish_dynamic_sections \ | |
4344 | elf32_tic6x_finish_dynamic_sections | |
c6a8f6e0 BS |
4345 | #define bfd_elf32_bfd_final_link \ |
4346 | elf32_tic6x_final_link | |
fbd9ad90 | 4347 | #define elf_backend_write_section elf32_tic6x_write_section |
40b36596 | 4348 | #define elf_info_to_howto elf32_tic6x_info_to_howto |
41820509 | 4349 | #define elf_info_to_howto_rel elf32_tic6x_info_to_howto_rel |
40b36596 | 4350 | |
ac145307 BS |
4351 | #undef elf_backend_omit_section_dynsym |
4352 | #define elf_backend_omit_section_dynsym elf32_tic6x_link_omit_section_dynsym | |
4353 | #define elf_backend_plt_sym_val elf32_tic6x_plt_sym_val | |
4354 | ||
2a616379 BS |
4355 | #include "elf32-target.h" |
4356 | ||
4357 | #undef elf32_bed | |
4358 | #define elf32_bed elf32_tic6x_linux_bed | |
4359 | ||
4360 | #undef TARGET_LITTLE_SYM | |
6d00b590 | 4361 | #define TARGET_LITTLE_SYM tic6x_elf32_linux_le_vec |
2a616379 BS |
4362 | #undef TARGET_LITTLE_NAME |
4363 | #define TARGET_LITTLE_NAME "elf32-tic6x-linux-le" | |
4364 | #undef TARGET_BIG_SYM | |
6d00b590 | 4365 | #define TARGET_BIG_SYM tic6x_elf32_linux_be_vec |
2a616379 BS |
4366 | #undef TARGET_BIG_NAME |
4367 | #define TARGET_BIG_NAME "elf32-tic6x-linux-be" | |
4368 | #undef ELF_OSABI | |
4369 | #define ELF_OSABI ELFOSABI_C6000_LINUX | |
4370 | ||
2a616379 BS |
4371 | #include "elf32-target.h" |
4372 | ||
4373 | #undef elf32_bed | |
4374 | #define elf32_bed elf32_tic6x_elf_bed | |
4375 | ||
4376 | #undef TARGET_LITTLE_SYM | |
6d00b590 | 4377 | #define TARGET_LITTLE_SYM tic6x_elf32_c6000_le_vec |
2a616379 BS |
4378 | #undef TARGET_LITTLE_NAME |
4379 | #define TARGET_LITTLE_NAME "elf32-tic6x-elf-le" | |
4380 | #undef TARGET_BIG_SYM | |
6d00b590 | 4381 | #define TARGET_BIG_SYM tic6x_elf32_c6000_be_vec |
2a616379 BS |
4382 | #undef TARGET_BIG_NAME |
4383 | #define TARGET_BIG_NAME "elf32-tic6x-elf-be" | |
4384 | #undef ELF_OSABI | |
4385 | #define ELF_OSABI ELFOSABI_C6000_ELFABI | |
4386 | ||
40b36596 | 4387 | #include "elf32-target.h" |