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