1 /* 32-bit ELF support for TI C6X
2 Copyright (C) 2010-2024 Free Software Foundation, Inc.
3 Contributed by Joseph Myers <joseph@codesourcery.com>
4 Bernd Schmidt <bernds@codesourcery.com>
6 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
27 #include "libiberty.h"
29 #include "elf/tic6x.h"
30 #include "elf32-tic6x.h"
32 #define ELF_DYNAMIC_INTERPRETER "/lib/ld-uClibc.so.0"
34 /* DSBT binaries have a default 128K stack. */
35 #define DEFAULT_STACK_SIZE 0x20000
37 /* The size in bytes of an entry in the procedure linkage table. */
38 #define PLT_ENTRY_SIZE 24
40 /* TI C6X ELF linker hash table. */
42 struct elf32_tic6x_link_hash_table
44 struct elf_link_hash_table elf
;
46 /* C6X specific command line arguments. */
47 struct elf32_tic6x_params params
;
49 /* The output BFD, for convenience. */
52 /* The .dsbt section. */
56 /* Get the TI C6X ELF linker hash table from a link_info structure. */
58 #define elf32_tic6x_hash_table(p) \
59 ((struct elf32_tic6x_link_hash_table *) ((p)->hash))
64 INSERT_EXIDX_CANTUNWIND_AT_END
66 tic6x_unwind_edit_type
;
68 /* A (sorted) list of edits to apply to an unwind table. */
69 typedef struct tic6x_unwind_table_edit
71 tic6x_unwind_edit_type type
;
72 /* Note: we sometimes want to insert an unwind entry corresponding to a
73 section different from the one we're currently writing out, so record the
74 (text) section this edit relates to here. */
75 asection
*linked_section
;
77 struct tic6x_unwind_table_edit
*next
;
79 tic6x_unwind_table_edit
;
81 typedef struct _tic6x_elf_section_data
83 /* Information about mapping symbols. */
84 struct bfd_elf_section_data elf
;
85 /* Information about unwind tables. */
88 /* Unwind info attached to a text section. */
91 asection
*tic6x_exidx_sec
;
94 /* Unwind info attached to an .c6xabi.exidx section. */
97 tic6x_unwind_table_edit
*unwind_edit_list
;
98 tic6x_unwind_table_edit
*unwind_edit_tail
;
102 _tic6x_elf_section_data
;
104 #define elf32_tic6x_section_data(sec) \
105 ((_tic6x_elf_section_data *) elf_section_data (sec))
107 struct elf32_tic6x_obj_tdata
109 struct elf_obj_tdata root
;
111 /* Whether to use RELA relocations when generating relocations.
112 This is a per-object flag to allow the assembler to generate REL
113 relocations for use in linker testcases. */
117 #define elf32_tic6x_tdata(abfd) \
118 ((struct elf32_tic6x_obj_tdata *) (abfd)->tdata.any)
120 #define is_tic6x_elf(bfd) \
121 (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
122 && elf_tdata (bfd) != NULL \
123 && elf_object_id (bfd) == TIC6X_ELF_DATA)
125 /* C6X ELF uses two common sections. One is the usual one, and the
126 other is for small objects. All the small objects are kept
127 together, and then referenced via the gp pointer, which yields
128 faster assembler code. This is what we use for the small common
129 section. This approach is copied from ecoff.c. */
130 static asection tic6x_elf_scom_section
;
131 static const asymbol tic6x_elf_scom_symbol
=
132 GLOBAL_SYM_INIT (".scommon", &tic6x_elf_scom_section
);
133 static asection tic6x_elf_scom_section
=
134 BFD_FAKE_SECTION (tic6x_elf_scom_section
, &tic6x_elf_scom_symbol
,
135 ".scommon", 0, SEC_IS_COMMON
| SEC_SMALL_DATA
);
137 static reloc_howto_type elf32_tic6x_howto_table
[] =
139 HOWTO (R_C6000_NONE
, /* type */
143 false, /* pc_relative */
145 complain_overflow_dont
,/* complain_on_overflow */
146 bfd_elf_generic_reloc
, /* special_function */
147 "R_C6000_NONE", /* name */
148 false, /* partial_inplace */
151 false), /* pcrel_offset */
152 HOWTO (R_C6000_ABS32
, /* type */
156 false, /* pc_relative */
158 complain_overflow_dont
,/* complain_on_overflow */
159 bfd_elf_generic_reloc
, /* special_function */
160 "R_C6000_ABS32", /* name */
161 false, /* partial_inplace */
163 0xffffffff, /* dst_mask */
164 false), /* pcrel_offset */
165 HOWTO (R_C6000_ABS16
, /* type */
169 false, /* pc_relative */
171 complain_overflow_bitfield
,/* complain_on_overflow */
172 bfd_elf_generic_reloc
, /* special_function */
173 "R_C6000_ABS16", /* name */
174 false, /* partial_inplace */
176 0x0000ffff, /* dst_mask */
177 false), /* pcrel_offset */
178 HOWTO (R_C6000_ABS8
, /* type */
182 false, /* pc_relative */
184 complain_overflow_bitfield
,/* complain_on_overflow */
185 bfd_elf_generic_reloc
, /* special_function */
186 "R_C6000_ABS8", /* name */
187 false, /* partial_inplace */
189 0x000000ff, /* dst_mask */
190 false), /* pcrel_offset */
191 HOWTO (R_C6000_PCR_S21
, /* type */
195 true, /* pc_relative */
197 complain_overflow_signed
,/* complain_on_overflow */
198 bfd_elf_generic_reloc
, /* special_function */
199 "R_C6000_PCR_S21", /* name */
200 false, /* partial_inplace */
202 0x0fffff80, /* dst_mask */
203 true), /* pcrel_offset */
204 HOWTO (R_C6000_PCR_S12
, /* type */
208 true, /* pc_relative */
210 complain_overflow_signed
,/* complain_on_overflow */
211 bfd_elf_generic_reloc
, /* special_function */
212 "R_C6000_PCR_S12", /* name */
213 false, /* partial_inplace */
215 0x0fff0000, /* dst_mask */
216 true), /* pcrel_offset */
217 HOWTO (R_C6000_PCR_S10
, /* type */
221 true, /* pc_relative */
223 complain_overflow_signed
,/* complain_on_overflow */
224 bfd_elf_generic_reloc
, /* special_function */
225 "R_C6000_PCR_S10", /* name */
226 false, /* partial_inplace */
228 0x007fe000, /* dst_mask */
229 true), /* pcrel_offset */
230 HOWTO (R_C6000_PCR_S7
, /* type */
234 true, /* pc_relative */
236 complain_overflow_signed
,/* complain_on_overflow */
237 bfd_elf_generic_reloc
, /* special_function */
238 "R_C6000_PCR_S7", /* name */
239 false, /* partial_inplace */
241 0x007f0000, /* dst_mask */
242 true), /* pcrel_offset */
243 HOWTO (R_C6000_ABS_S16
, /* type */
247 false, /* pc_relative */
249 complain_overflow_signed
,/* complain_on_overflow */
250 bfd_elf_generic_reloc
, /* special_function */
251 "R_C6000_ABS_S16", /* name */
252 false, /* partial_inplace */
254 0x007fff80, /* dst_mask */
255 false), /* pcrel_offset */
256 HOWTO (R_C6000_ABS_L16
, /* type */
260 false, /* pc_relative */
262 complain_overflow_dont
,/* complain_on_overflow */
263 bfd_elf_generic_reloc
, /* special_function */
264 "R_C6000_ABS_L16", /* name */
265 false, /* partial_inplace */
267 0x007fff80, /* dst_mask */
268 false), /* pcrel_offset */
269 HOWTO (R_C6000_ABS_H16
, /* type */
273 false, /* pc_relative */
275 complain_overflow_dont
,/* complain_on_overflow */
276 bfd_elf_generic_reloc
, /* special_function */
277 "R_C6000_ABS_H16", /* name */
278 false, /* partial_inplace */
280 0x007fff80, /* dst_mask */
281 false), /* pcrel_offset */
282 HOWTO (R_C6000_SBR_U15_B
, /* type */
286 false, /* pc_relative */
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 */
293 0x007fff00, /* dst_mask */
294 false), /* pcrel_offset */
295 HOWTO (R_C6000_SBR_U15_H
, /* type */
299 false, /* pc_relative */
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 */
306 0x007fff00, /* dst_mask */
307 false), /* pcrel_offset */
308 HOWTO (R_C6000_SBR_U15_W
, /* type */
312 false, /* pc_relative */
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 */
319 0x007fff00, /* dst_mask */
320 false), /* pcrel_offset */
321 HOWTO (R_C6000_SBR_S16
, /* type */
325 false, /* pc_relative */
327 complain_overflow_signed
,/* complain_on_overflow */
328 bfd_elf_generic_reloc
, /* special_function */
329 "R_C6000_SBR_S16", /* name */
330 false, /* partial_inplace */
332 0x007fff80, /* dst_mask */
333 false), /* pcrel_offset */
334 HOWTO (R_C6000_SBR_L16_B
, /* type */
338 false, /* pc_relative */
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 */
345 0x007fff80, /* dst_mask */
346 false), /* pcrel_offset */
347 HOWTO (R_C6000_SBR_L16_H
, /* type */
351 false, /* pc_relative */
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 */
358 0x007fff80, /* dst_mask */
359 false), /* pcrel_offset */
360 HOWTO (R_C6000_SBR_L16_W
, /* type */
364 false, /* pc_relative */
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 */
371 0x007fff80, /* dst_mask */
372 false), /* pcrel_offset */
373 HOWTO (R_C6000_SBR_H16_B
, /* type */
377 false, /* pc_relative */
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 */
384 0x007fff80, /* dst_mask */
385 false), /* pcrel_offset */
386 HOWTO (R_C6000_SBR_H16_H
, /* type */
390 false, /* pc_relative */
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 */
397 0x007fff80, /* dst_mask */
398 false), /* pcrel_offset */
399 HOWTO (R_C6000_SBR_H16_W
, /* type */
403 false, /* pc_relative */
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 */
410 0x007fff80, /* dst_mask */
411 false), /* pcrel_offset */
412 HOWTO (R_C6000_SBR_GOT_U15_W
, /* type */
416 false, /* pc_relative */
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 */
423 0x007fff00, /* dst_mask */
424 false), /* pcrel_offset */
425 HOWTO (R_C6000_SBR_GOT_L16_W
, /* type */
429 false, /* pc_relative */
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 */
436 0x007fff80, /* dst_mask */
437 false), /* pcrel_offset */
438 HOWTO (R_C6000_SBR_GOT_H16_W
, /* type */
442 false, /* pc_relative */
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 */
449 0x007fff80, /* dst_mask */
450 false), /* pcrel_offset */
451 HOWTO (R_C6000_DSBT_INDEX
, /* type */
455 false, /* pc_relative */
457 complain_overflow_unsigned
,/* complain_on_overflow */
458 bfd_elf_generic_reloc
, /* special_function */
459 "R_C6000_DSBT_INDEX", /* name */
460 false, /* partial_inplace */
462 0x007fff00, /* dst_mask */
463 false), /* pcrel_offset */
464 HOWTO (R_C6000_PREL31
, /* type */
468 true, /* pc_relative */
470 complain_overflow_dont
,/* complain_on_overflow */
471 bfd_elf_generic_reloc
, /* special_function */
472 "R_C6000_PREL31", /* name */
473 false, /* partial_inplace */
475 0x7fffffff, /* dst_mask */
476 true), /* pcrel_offset */
477 HOWTO (R_C6000_COPY
, /* type */
481 false, /* pc_relative */
483 complain_overflow_dont
,/* complain_on_overflow */
484 bfd_elf_generic_reloc
, /* special_function */
485 "R_C6000_COPY", /* name */
486 false, /* partial_inplace */
488 0xffffffff, /* dst_mask */
489 false), /* pcrel_offset */
490 HOWTO (R_C6000_JUMP_SLOT
, /* type */
494 false, /* pc_relative */
496 complain_overflow_dont
,/* complain_on_overflow */
497 bfd_elf_generic_reloc
, /* special_function */
498 "R_C6000_JUMP_SLOT", /* name */
499 false, /* partial_inplace */
501 0xffffffff, /* dst_mask */
502 false), /* pcrel_offset */
503 HOWTO (R_C6000_EHTYPE
, /* type */
507 false, /* pc_relative */
509 complain_overflow_dont
,/* complain_on_overflow */
510 bfd_elf_generic_reloc
, /* special_function */
511 "R_C6000_EHTYPE", /* name */
512 false, /* partial_inplace */
514 0xffffffff, /* dst_mask */
515 false), /* pcrel_offset */
516 HOWTO (R_C6000_PCR_H16
, /* type */
520 true, /* pc_relative */
522 complain_overflow_dont
,/* complain_on_overflow */
523 bfd_elf_generic_reloc
, /* special_function */
524 "R_C6000_PCR_H16", /* name */
525 false, /* partial_inplace */
527 0x007fff80, /* dst_mask */
528 true), /* pcrel_offset */
529 HOWTO (R_C6000_PCR_L16
, /* type */
533 true, /* pc_relative */
535 complain_overflow_dont
,/* complain_on_overflow */
536 bfd_elf_generic_reloc
, /* special_function */
537 "R_C6000_PCR_L16", /* name */
538 false, /* partial_inplace */
540 0x007fff80, /* dst_mask */
541 true), /* pcrel_offset */
764 HOWTO (R_C6000_ALIGN
, /* type */
768 false, /* pc_relative */
770 complain_overflow_dont
,/* complain_on_overflow */
771 bfd_elf_generic_reloc
, /* special_function */
772 "R_C6000_ALIGN", /* name */
773 false, /* partial_inplace */
776 false), /* pcrel_offset */
777 HOWTO (R_C6000_FPHEAD
, /* type */
781 false, /* pc_relative */
783 complain_overflow_dont
,/* complain_on_overflow */
784 bfd_elf_generic_reloc
, /* special_function */
785 "R_C6000_FPHEAD", /* name */
786 false, /* partial_inplace */
789 false), /* pcrel_offset */
790 HOWTO (R_C6000_NOCMP
, /* type */
794 false, /* pc_relative */
796 complain_overflow_dont
,/* complain_on_overflow */
797 bfd_elf_generic_reloc
, /* special_function */
798 "R_C6000_NOCMP", /* name */
799 false, /* partial_inplace */
802 false) /* pcrel_offset */
805 static reloc_howto_type elf32_tic6x_howto_table_rel
[] =
807 HOWTO (R_C6000_NONE
, /* type */
811 false, /* pc_relative */
813 complain_overflow_dont
,/* complain_on_overflow */
814 bfd_elf_generic_reloc
, /* special_function */
815 "R_C6000_NONE", /* name */
816 true, /* partial_inplace */
819 false), /* pcrel_offset */
820 HOWTO (R_C6000_ABS32
, /* type */
824 false, /* pc_relative */
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 */
837 false, /* pc_relative */
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 */
850 false, /* pc_relative */
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 */
863 true, /* pc_relative */
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 */
876 true, /* pc_relative */
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 */
889 true, /* pc_relative */
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 */
902 true, /* pc_relative */
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 */
915 false, /* pc_relative */
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 */
928 false, /* pc_relative */
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 */
942 false, /* pc_relative */
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 */
955 false, /* pc_relative */
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 */
968 false, /* pc_relative */
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 */
981 false, /* pc_relative */
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 */
994 false, /* pc_relative */
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 */
1007 false, /* pc_relative */
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 */
1020 false, /* pc_relative */
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 */
1036 false, /* pc_relative */
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 */
1049 false, /* pc_relative */
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 */
1063 false, /* pc_relative */
1065 complain_overflow_unsigned
,/* complain_on_overflow */
1066 bfd_elf_generic_reloc
, /* special_function */
1067 "R_C6000_DSBT_INDEX", /* name */
1068 true, /* partial_inplace */
1070 0x007fff00, /* dst_mask */
1071 false), /* pcrel_offset */
1072 HOWTO (R_C6000_PREL31
, /* type */
1076 true, /* pc_relative */
1078 complain_overflow_dont
,/* complain_on_overflow */
1079 bfd_elf_generic_reloc
, /* special_function */
1080 "R_C6000_PREL31", /* name */
1081 true, /* partial_inplace */
1083 0x7fffffff, /* dst_mask */
1084 true), /* pcrel_offset */
1085 HOWTO (R_C6000_COPY
, /* type */
1089 false, /* pc_relative */
1091 complain_overflow_dont
,/* complain_on_overflow */
1092 bfd_elf_generic_reloc
, /* special_function */
1093 "R_C6000_COPY", /* name */
1094 true, /* partial_inplace */
1096 0xffffffff, /* dst_mask */
1097 false), /* pcrel_offset */
1098 HOWTO (R_C6000_JUMP_SLOT
, /* type */
1102 false, /* pc_relative */
1104 complain_overflow_dont
,/* complain_on_overflow */
1105 bfd_elf_generic_reloc
, /* special_function */
1106 "R_C6000_JUMP_SLOT", /* name */
1107 false, /* partial_inplace */
1109 0xffffffff, /* dst_mask */
1110 false), /* pcrel_offset */
1111 HOWTO (R_C6000_EHTYPE
, /* type */
1115 false, /* pc_relative */
1117 complain_overflow_dont
,/* complain_on_overflow */
1118 bfd_elf_generic_reloc
, /* special_function */
1119 "R_C6000_EHTYPE", /* name */
1120 false, /* partial_inplace */
1122 0xffffffff, /* dst_mask */
1123 false), /* pcrel_offset */
1124 EMPTY_HOWTO (R_C6000_PCR_H16
),
1125 EMPTY_HOWTO (R_C6000_PCR_L16
),
1348 HOWTO (R_C6000_ALIGN
, /* type */
1352 false, /* pc_relative */
1354 complain_overflow_dont
,/* complain_on_overflow */
1355 bfd_elf_generic_reloc
, /* special_function */
1356 "R_C6000_ALIGN", /* name */
1357 true, /* partial_inplace */
1360 false), /* pcrel_offset */
1361 HOWTO (R_C6000_FPHEAD
, /* type */
1365 false, /* pc_relative */
1367 complain_overflow_dont
,/* complain_on_overflow */
1368 bfd_elf_generic_reloc
, /* special_function */
1369 "R_C6000_FPHEAD", /* name */
1370 true, /* partial_inplace */
1373 false), /* pcrel_offset */
1374 HOWTO (R_C6000_NOCMP
, /* type */
1378 false, /* pc_relative */
1380 complain_overflow_dont
,/* complain_on_overflow */
1381 bfd_elf_generic_reloc
, /* special_function */
1382 "R_C6000_NOCMP", /* name */
1383 true, /* partial_inplace */
1386 false) /* pcrel_offset */
1389 /* Map BFD relocations to ELF relocations. */
1393 bfd_reloc_code_real_type bfd_reloc_val
;
1394 enum elf_tic6x_reloc_type elf_reloc_val
;
1397 static const tic6x_reloc_map elf32_tic6x_reloc_map
[] =
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
}
1435 static reloc_howto_type
*
1436 elf32_tic6x_reloc_type_lookup (bfd
*abfd
, bfd_reloc_code_real_type code
)
1440 for (i
= 0; i
< ARRAY_SIZE (elf32_tic6x_reloc_map
); i
++)
1441 if (elf32_tic6x_reloc_map
[i
].bfd_reloc_val
== code
)
1443 enum elf_tic6x_reloc_type elf_reloc_val
;
1444 reloc_howto_type
*howto
;
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
];
1450 howto
= &elf32_tic6x_howto_table_rel
[elf_reloc_val
];
1452 /* Some relocations are RELA-only; do not return them for
1454 if (howto
->name
== NULL
)
1463 static reloc_howto_type
*
1464 elf32_tic6x_reloc_name_lookup (bfd
*abfd
, const char *r_name
)
1466 if (elf32_tic6x_tdata (abfd
)->use_rela_p
)
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
];
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
];
1489 elf32_tic6x_info_to_howto (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*bfd_reloc
,
1490 Elf_Internal_Rela
*elf_reloc
)
1492 unsigned int r_type
;
1494 r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
1495 if (r_type
>= ARRAY_SIZE (elf32_tic6x_howto_table
))
1497 /* xgettext:c-format */
1498 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1500 bfd_set_error (bfd_error_bad_value
);
1504 bfd_reloc
->howto
= &elf32_tic6x_howto_table
[r_type
];
1505 if (bfd_reloc
->howto
== NULL
|| bfd_reloc
->howto
->name
== NULL
)
1507 /* xgettext:c-format */
1508 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1510 bfd_set_error (bfd_error_bad_value
);
1518 elf32_tic6x_info_to_howto_rel (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*bfd_reloc
,
1519 Elf_Internal_Rela
*elf_reloc
)
1521 unsigned int r_type
;
1523 r_type
= ELF32_R_TYPE (elf_reloc
->r_info
);
1524 if (r_type
>= ARRAY_SIZE (elf32_tic6x_howto_table_rel
))
1526 /* xgettext:c-format */
1527 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1529 bfd_set_error (bfd_error_bad_value
);
1533 bfd_reloc
->howto
= &elf32_tic6x_howto_table_rel
[r_type
];
1534 if (bfd_reloc
->howto
== NULL
|| bfd_reloc
->howto
->name
== NULL
)
1536 /* xgettext:c-format */
1537 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1539 bfd_set_error (bfd_error_bad_value
);
1547 elf32_tic6x_set_use_rela_p (bfd
*abfd
, bool use_rela_p
)
1549 elf32_tic6x_tdata (abfd
)->use_rela_p
= use_rela_p
;
1552 /* Create a C6X ELF linker hash table. */
1554 static struct bfd_link_hash_table
*
1555 elf32_tic6x_link_hash_table_create (bfd
*abfd
)
1557 struct elf32_tic6x_link_hash_table
*ret
;
1558 size_t amt
= sizeof (struct elf32_tic6x_link_hash_table
);
1560 ret
= bfd_zmalloc (amt
);
1564 if (!_bfd_elf_link_hash_table_init (&ret
->elf
, abfd
,
1565 _bfd_elf_link_hash_newfunc
,
1566 sizeof (struct elf_link_hash_entry
),
1574 ret
->elf
.is_relocatable_executable
= 1;
1576 return &ret
->elf
.root
;
1580 elf32_tic6x_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
1582 if (bfd_link_pic (info
))
1584 obj_attribute
*out_attr
;
1585 out_attr
= elf_known_obj_attributes_proc (abfd
);
1586 if (out_attr
[Tag_ABI_PIC
].i
== 0)
1588 _bfd_error_handler (_("warning: generating a shared library "
1589 "containing non-PIC code"));
1591 if (out_attr
[Tag_ABI_PID
].i
== 0)
1593 _bfd_error_handler (_("warning: generating a shared library "
1594 "containing non-PID code"));
1597 /* Invoke the regular ELF backend linker to do all the work. */
1598 if (!bfd_elf_final_link (abfd
, info
))
1604 /* Called to pass PARAMS to the backend. We store them in the hash table
1605 associated with INFO. */
1608 elf32_tic6x_setup (struct bfd_link_info
*info
,
1609 struct elf32_tic6x_params
*params
)
1611 struct elf32_tic6x_link_hash_table
*htab
= elf32_tic6x_hash_table (info
);
1612 htab
->params
= *params
;
1615 /* Determine if we're dealing with a DSBT object. */
1618 elf32_tic6x_using_dsbt (bfd
*abfd
)
1620 return bfd_elf_get_obj_attr_int (abfd
, OBJ_ATTR_PROC
,
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
1629 elf32_tic6x_create_dynamic_sections (bfd
*dynobj
, struct bfd_link_info
*info
)
1631 struct elf32_tic6x_link_hash_table
*htab
;
1634 htab
= elf32_tic6x_hash_table (info
);
1638 if (!_bfd_elf_create_dynamic_sections (dynobj
, info
))
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",
1646 if (htab
->dsbt
== NULL
1647 || !bfd_set_section_alignment (htab
->dsbt
, 2)
1648 || !bfd_set_section_alignment (htab
->elf
.splt
, 5))
1655 elf32_tic6x_mkobject (bfd
*abfd
)
1659 ret
= bfd_elf_allocate_object (abfd
, sizeof (struct elf32_tic6x_obj_tdata
),
1662 elf32_tic6x_set_use_rela_p (abfd
, true);
1666 /* Install relocation RELA into section SRELA, incrementing its
1670 elf32_tic6x_install_rela (bfd
*output_bfd
, asection
*srela
,
1671 Elf_Internal_Rela
*rela
)
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
);
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. */
1684 elf32_tic6x_make_got_dynreloc (bfd
*output_bfd
,
1685 struct elf32_tic6x_link_hash_table
*htab
,
1686 asection
*sym_sec
, bfd_vma offset
)
1688 asection
*sgot
= htab
->elf
.sgot
;
1689 Elf_Internal_Rela outrel
;
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
))
1698 dynindx
= elf_section_data (sym_sec
->output_section
)->dynindx
;
1699 outrel
.r_addend
-= sym_sec
->output_section
->vma
;
1705 outrel
.r_info
= ELF32_R_INFO (dynindx
, R_C6000_ABS32
);
1706 elf32_tic6x_install_rela (output_bfd
, htab
->elf
.srelgot
, &outrel
);
1709 /* Finish up dynamic symbol handling. We set the contents of various
1710 dynamic sections here. */
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
)
1718 struct elf32_tic6x_link_hash_table
*htab
;
1720 htab
= elf32_tic6x_hash_table (info
);
1722 if (h
->plt
.offset
!= (bfd_vma
) -1)
1725 bfd_vma got_section_offset
, got_dp_offset
, rela_offset
;
1726 Elf_Internal_Rela rela
;
1728 asection
*plt
, *gotplt
, *relplt
;
1729 const struct elf_backend_data
*bed
;
1731 bed
= get_elf_backend_data (output_bfd
);
1733 BFD_ASSERT (htab
->elf
.splt
!= NULL
);
1734 plt
= htab
->elf
.splt
;
1735 gotplt
= htab
->elf
.sgotplt
;
1736 relplt
= htab
->elf
.srelplt
;
1738 /* This symbol has an entry in the procedure linkage table. Set
1741 if ((h
->dynindx
== -1
1742 && !((h
->forced_local
|| bfd_link_executable (info
))
1744 && h
->type
== STT_GNU_IFUNC
))
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.
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.
1759 For static executables, we don't reserve anything. */
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
);
1766 got_section_offset
*= 4;
1768 /* Fill in the entry in the procedure linkage table. */
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);
1780 bfd_put_32 (output_bfd
, 0x00002000,
1781 plt
->contents
+ h
->plt
.offset
+ 12);
1783 bfd_put_32 (output_bfd
, 0x00080362,
1784 plt
->contents
+ h
->plt
.offset
+ 16);
1786 bfd_put_32 (output_bfd
, 0x00008000,
1787 plt
->contents
+ h
->plt
.offset
+ 20);
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
);
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
);
1800 loc
= relplt
->contents
+ rela_offset
;
1801 bfd_elf32_swap_reloca_out (output_bfd
, &rela
, loc
);
1803 if (!h
->def_regular
)
1805 /* Mark the symbol as undefined, rather than as defined in
1806 the .plt section. */
1807 sym
->st_shndx
= SHN_UNDEF
;
1812 if (h
->got
.offset
!= (bfd_vma
) -1)
1817 /* This symbol has an entry in the global offset table.
1820 sgot
= htab
->elf
.sgot
;
1821 srela
= htab
->elf
.srelgot
;
1822 BFD_ASSERT (sgot
!= NULL
&& srela
!= NULL
);
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
)
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);
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;
1848 elf32_tic6x_install_rela (output_bfd
, srela
, &outrel
);
1854 Elf_Internal_Rela rel
;
1857 /* This symbol needs a copy reloc. Set it up. */
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
)
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
);
1871 if (h
->root
.u
.def
.section
== htab
->elf
.sdynrelro
)
1872 s
= htab
->elf
.sreldynrelro
;
1874 s
= htab
->elf
.srelbss
;
1876 elf32_tic6x_install_rela (output_bfd
, s
, &rel
);
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
;
1887 /* Unwinding tables are not referenced directly. This pass marks them as
1888 required if the corresponding code section is marked. */
1891 elf32_tic6x_gc_mark_extra_sections (struct bfd_link_info
*info
,
1892 elf_gc_mark_hook_fn gc_mark_hook
)
1895 Elf_Internal_Shdr
**elf_shdrp
;
1898 _bfd_elf_gc_mark_extra_sections (info
, gc_mark_hook
);
1900 /* Marking EH data may cause additional code sections to be marked,
1901 requiring multiple passes. */
1906 for (sub
= info
->input_bfds
; sub
!= NULL
; sub
= sub
->link
.next
)
1910 if (! is_tic6x_elf (sub
))
1913 elf_shdrp
= elf_elfsections (sub
);
1914 for (o
= sub
->sections
; o
!= NULL
; o
= o
->next
)
1916 Elf_Internal_Shdr
*hdr
;
1918 hdr
= &elf_section_data (o
)->this_hdr
;
1919 if (hdr
->sh_type
== SHT_C6000_UNWIND
1921 && hdr
->sh_link
< elf_numsections (sub
)
1923 && elf_shdrp
[hdr
->sh_link
]->bfd_section
->gc_mark
)
1926 if (!_bfd_elf_gc_mark (info
, o
, gc_mark_hook
))
1936 /* Return TRUE if this is an unwinding table index. */
1939 is_tic6x_elf_unwind_section_name (const char *name
)
1941 return (startswith (name
, ELF_STRING_C6000_unwind
)
1942 || startswith (name
, ELF_STRING_C6000_unwind_once
));
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. */
1950 elf32_tic6x_fake_sections (bfd
*abfd ATTRIBUTE_UNUSED
,
1951 Elf_Internal_Shdr
*hdr
, asection
*sec
)
1955 name
= bfd_section_name (sec
);
1957 if (is_tic6x_elf_unwind_section_name (name
))
1959 hdr
->sh_type
= SHT_C6000_UNWIND
;
1960 hdr
->sh_flags
|= SHF_LINK_ORDER
;
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
1973 elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info
*info
,
1974 struct elf_link_hash_entry
*h
)
1976 struct elf32_tic6x_link_hash_table
*htab
;
1980 dynobj
= elf_hash_table (info
)->dynobj
;
1982 /* Make sure we know what is going on here. */
1983 BFD_ASSERT (dynobj
!= NULL
1986 || (h
->def_dynamic
&& h
->ref_regular
&& !h
->def_regular
)));
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
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
))
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;
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
)
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
;
2024 /* This is a reference to a symbol defined by a dynamic object which
2025 is not a function. */
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
))
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
)
2039 /* If -z nocopyreloc was given, we won't generate them either. */
2040 if (info
->nocopyreloc
)
2046 htab
= elf32_tic6x_hash_table (info
);
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. */
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)
2065 s
= htab
->elf
.sdynrelro
;
2066 srel
= htab
->elf
.sreldynrelro
;
2070 s
= htab
->elf
.sdynbss
;
2071 srel
= htab
->elf
.srelbss
;
2073 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0 && h
->size
!= 0)
2075 srel
->size
+= sizeof (Elf32_External_Rela
);
2079 return _bfd_elf_adjust_dynamic_copy (info
, h
, s
);
2083 elf32_tic6x_new_section_hook (bfd
*abfd
, asection
*sec
)
2087 /* Allocate target specific section data. */
2088 if (!sec
->used_by_bfd
)
2090 _tic6x_elf_section_data
*sdata
;
2091 size_t amt
= sizeof (*sdata
);
2093 sdata
= (_tic6x_elf_section_data
*) bfd_zalloc (abfd
, amt
);
2096 sec
->used_by_bfd
= sdata
;
2099 ret
= _bfd_elf_new_section_hook (abfd
, sec
);
2100 sec
->use_rela_p
= elf32_tic6x_tdata (abfd
)->use_rela_p
;
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. */
2110 elf32_tic6x_rel_relocation_p (bfd
*abfd
, asection
*sec
,
2111 const Elf_Internal_Rela
*relocs
,
2112 const Elf_Internal_Rela
*rel
)
2114 Elf_Internal_Shdr
*rel_hdr
;
2115 const struct elf_backend_data
*bed
;
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
)
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
);
2127 /* We need dynamic symbols for every section, since segments can
2128 relocate independently. */
2130 elf32_tic6x_link_omit_section_dynsym (bfd
*output_bfd ATTRIBUTE_UNUSED
,
2131 struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2134 switch (elf_section_data (p
)->this_hdr
.sh_type
)
2138 /* If sh_type is yet undecided, assume it could be
2139 SHT_PROGBITS/SHT_NOBITS. */
2143 /* There shouldn't be section relative relocations
2144 against any other section. */
2151 elf32_tic6x_relocate_section (bfd
*output_bfd
,
2152 struct bfd_link_info
*info
,
2154 asection
*input_section
,
2156 Elf_Internal_Rela
*relocs
,
2157 Elf_Internal_Sym
*local_syms
,
2158 asection
**local_sections
)
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
;
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
);
2173 relend
= relocs
+ input_section
->reloc_count
;
2175 for (rel
= relocs
; rel
< relend
; rel
++)
2178 unsigned long r_symndx
;
2180 reloc_howto_type
*howto
;
2181 Elf_Internal_Sym
*sym
;
2183 struct elf_link_hash_entry
*h
;
2184 bfd_vma off
, off2
, relocation
;
2185 bool unresolved_reloc
;
2186 bfd_reloc_status_type r
;
2187 struct bfd_link_hash_entry
*sbh
;
2191 r_type
= ELF32_R_TYPE (rel
->r_info
);
2192 r_symndx
= ELF32_R_SYM (rel
->r_info
);
2194 is_rel
= elf32_tic6x_rel_relocation_p (input_bfd
, input_section
,
2198 res
= elf32_tic6x_info_to_howto_rel (input_bfd
, &bfd_reloc
, rel
);
2200 res
= elf32_tic6x_info_to_howto (input_bfd
, &bfd_reloc
, rel
);
2202 if (!res
|| (howto
= bfd_reloc
.howto
) == NULL
)
2204 bfd_set_error (bfd_error_bad_value
);
2211 unresolved_reloc
= false;
2213 if (r_symndx
< symtab_hdr
->sh_info
)
2215 sym
= local_syms
+ r_symndx
;
2216 sec
= local_sections
[r_symndx
];
2217 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
2221 bool warned
, ignored
;
2223 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
2224 r_symndx
, symtab_hdr
, sym_hashes
,
2226 unresolved_reloc
, warned
, ignored
);
2229 if (sec
!= NULL
&& discarded_section (sec
))
2230 RELOC_AGAINST_DISCARDED_SECTION (info
, input_bfd
, input_section
,
2231 rel
, 1, relend
, howto
, 0, contents
);
2233 if (bfd_link_relocatable (info
))
2237 && ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
2240 relocation
= sec
->output_offset
+ sym
->st_value
;
2241 r
= _bfd_relocate_contents (howto
, input_bfd
, relocation
,
2242 contents
+ rel
->r_offset
);
2252 case R_C6000_FPHEAD
:
2254 /* No action needed. */
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
))
2265 unsigned long oldval
;
2266 oldval
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
2268 if ((oldval
& 0x7e) == 0x12)
2270 oldval
&= 0xF0000001;
2271 bfd_put_32 (input_bfd
, oldval
| 0x000c0362,
2272 contents
+ rel
->r_offset
);
2279 case R_C6000_PCR_S12
:
2280 case R_C6000_PCR_S10
:
2281 case R_C6000_PCR_S7
:
2283 && h
->plt
.offset
!= (bfd_vma
) -1
2284 && htab
->elf
.splt
!= NULL
)
2286 relocation
= (htab
->elf
.splt
->output_section
->vma
2287 + htab
->elf
.splt
->output_offset
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;
2300 case R_C6000_PCR_H16
:
2301 case R_C6000_PCR_L16
:
2302 off
= (input_section
->output_section
->vma
2303 + input_section
->output_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
;
2314 case R_C6000_DSBT_INDEX
:
2315 relocation
= elf32_tic6x_hash_table (info
)->params
.dsbt_index
;
2316 if (!bfd_link_pic (info
) || relocation
!= 0)
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
2329 if ((bfd_link_pic (info
) || elf32_tic6x_using_dsbt (output_bfd
))
2330 && (input_section
->flags
& SEC_ALLOC
)
2332 || ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
2333 || h
->root
.type
!= bfd_link_hash_undefweak
))
2335 Elf_Internal_Rela outrel
;
2336 bool skip
, relocate
;
2339 unresolved_reloc
= false;
2341 sreloc
= elf_section_data (input_section
)->sreloc
;
2342 BFD_ASSERT (sreloc
!= NULL
&& sreloc
->contents
!= NULL
);
2348 _bfd_elf_section_offset (output_bfd
, info
, input_section
,
2350 if (outrel
.r_offset
== (bfd_vma
) -1)
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
);
2358 memset (&outrel
, 0, sizeof outrel
);
2361 && (!bfd_link_pic (info
)
2362 || !SYMBOLIC_BIND (info
, h
)
2363 || !h
->def_regular
))
2365 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
2366 outrel
.r_addend
= rel
->r_addend
;
2372 outrel
.r_addend
= relocation
+ rel
->r_addend
;
2374 if (bfd_is_abs_section (sec
))
2376 else if (sec
== NULL
|| sec
->owner
== NULL
)
2378 bfd_set_error (bfd_error_bad_value
);
2385 osec
= sec
->output_section
;
2386 indx
= elf_section_data (osec
)->dynindx
;
2387 outrel
.r_addend
-= osec
->vma
;
2388 BFD_ASSERT (indx
!= 0);
2391 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
2394 elf32_tic6x_install_rela (output_bfd
, sreloc
, &outrel
);
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. */
2403 /* Generic logic OK. */
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);
2419 && (sbh
->type
== bfd_link_hash_defined
2420 || sbh
->type
== bfd_link_hash_defweak
))
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
))
2428 relocation
-= (sbh
->u
.def
.value
2429 + sbh
->u
.def
.section
->output_section
->vma
2430 + sbh
->u
.def
.section
->output_offset
);
2434 _bfd_error_handler (_("%pB: SB-relative relocation but "
2435 "__c6xabi_DSBT_BASE not defined"),
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
2448 if (htab
->elf
.sgot
== NULL
)
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
),
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
))
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.
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. */
2481 bfd_put_32 (output_bfd
, relocation
,
2482 htab
->elf
.sgot
->contents
+ off
);
2485 if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn
,
2486 bfd_link_pic (info
),
2488 && !(ELF_ST_VISIBILITY (h
->other
)
2489 && h
->root
.type
== bfd_link_hash_undefweak
))
2490 elf32_tic6x_make_got_dynreloc (output_bfd
, htab
, sec
,
2495 unresolved_reloc
= false;
2499 if (local_got_offsets
== NULL
)
2502 off
= local_got_offsets
[r_symndx
];
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. */
2511 bfd_put_32 (output_bfd
, relocation
,
2512 htab
->elf
.sgot
->contents
+ off
);
2514 if (bfd_link_pic (info
) || elf32_tic6x_using_dsbt (output_bfd
))
2515 elf32_tic6x_make_got_dynreloc (output_bfd
, htab
, sec
, off
);
2517 local_got_offsets
[r_symndx
] |= 1;
2521 if (off
>= (bfd_vma
) -2)
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
);
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
);
2535 if (rel
->r_addend
!= 0)
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. */
2543 /* xgettext:c-format */
2544 (_("%pB, section %pA: relocation %s with non-zero addend %"
2545 PRId64
" against local symbol"),
2548 elf32_tic6x_howto_table
[r_type
].name
,
2549 (int64_t) rel
->r_addend
);
2552 /* xgettext:c-format */
2553 (_("%pB, section %pA: relocation %s with non-zero addend %"
2554 PRId64
" against symbol `%s'"),
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]"));
2562 bfd_set_error (bfd_error_bad_value
);
2567 case R_C6000_PREL31
:
2569 && h
->plt
.offset
!= (bfd_vma
) -1
2570 && htab
->elf
.splt
!= NULL
)
2572 relocation
= (htab
->elf
.splt
->output_section
->vma
2573 + htab
->elf
.splt
->output_offset
2579 /* Invalid in relocatable object. */
2581 /* Unknown relocation. */
2582 /* xgettext:c-format */
2583 _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
2585 bfd_set_error (bfd_error_bad_value
);
2590 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
2591 contents
, rel
->r_offset
,
2592 relocation
, rel
->r_addend
);
2595 if (r
== bfd_reloc_ok
2596 && howto
->complain_on_overflow
== complain_overflow_bitfield
)
2598 /* Generic overflow handling accepts cases the ABI says
2599 should be rejected for R_C6000_ABS16 and
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
;
2606 if (value_sbits
!= 0
2607 && value_sbits
!= sbit
2608 && value_sbits
!= sbits
)
2609 r
= bfd_reloc_overflow
;
2612 if (r
!= bfd_reloc_ok
)
2615 const char *error_message
;
2618 name
= h
->root
.root
.string
;
2621 name
= bfd_elf_string_from_elf_section (input_bfd
,
2622 symtab_hdr
->sh_link
,
2627 name
= bfd_section_name (sec
);
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
);
2642 case bfd_reloc_undefined
:
2643 (*info
->callbacks
->undefined_symbol
) (info
, name
, input_bfd
,
2645 rel
->r_offset
, true);
2648 case bfd_reloc_outofrange
:
2649 error_message
= _("out of range");
2652 case bfd_reloc_notsupported
:
2653 error_message
= _("unsupported relocation");
2656 case bfd_reloc_dangerous
:
2657 error_message
= _("dangerous relocation");
2661 error_message
= _("unknown error");
2665 BFD_ASSERT (error_message
!= NULL
);
2666 (*info
->callbacks
->reloc_dangerous
)
2667 (info
, error_message
, input_bfd
, input_section
, rel
->r_offset
);
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. */
2682 elf32_tic6x_check_relocs (bfd
*abfd
, struct bfd_link_info
*info
,
2683 asection
*sec
, const Elf_Internal_Rela
*relocs
)
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
;
2692 if (bfd_link_relocatable (info
))
2695 htab
= elf32_tic6x_hash_table (info
);
2696 symtab_hdr
= &elf_symtab_hdr (abfd
);
2697 sym_hashes
= elf_sym_hashes (abfd
);
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
)
2704 if (! _bfd_elf_link_create_dynamic_sections (abfd
, info
))
2710 rel_end
= relocs
+ sec
->reloc_count
;
2711 for (rel
= relocs
; rel
< rel_end
; rel
++)
2713 unsigned int r_type
;
2714 unsigned int r_symndx
;
2715 struct elf_link_hash_entry
*h
;
2716 Elf_Internal_Sym
*isym
;
2718 r_symndx
= ELF32_R_SYM (rel
->r_info
);
2719 r_type
= ELF32_R_TYPE (rel
->r_info
);
2721 if (r_symndx
>= NUM_SHDR_ENTRIES (symtab_hdr
))
2723 /* xgettext:c-format */
2724 _bfd_error_handler (_("%pB: bad symbol index: %d"),
2729 if (r_symndx
< symtab_hdr
->sh_info
)
2731 /* A local symbol. */
2732 isym
= bfd_sym_from_r_symndx (&htab
->elf
.sym_cache
,
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
;
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
2758 /* If this is a local symbol, we resolve it directly without
2759 creating a procedure linkage table entry. */
2764 h
->plt
.refcount
+= 1;
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. */
2774 h
->got
.refcount
+= 1;
2778 bfd_signed_vma
*local_got_refcounts
;
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
)
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
)
2792 elf_local_got_refcounts (abfd
) = local_got_refcounts
;
2794 local_got_refcounts
[r_symndx
] += 1;
2797 if (htab
->elf
.sgot
== NULL
)
2799 if (htab
->elf
.dynobj
== NULL
)
2800 htab
->elf
.dynobj
= abfd
;
2801 if (!_bfd_elf_create_got_section (htab
->elf
.dynobj
, info
))
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
))
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
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
2843 if ((bfd_link_pic (info
) || elf32_tic6x_using_dsbt (abfd
))
2844 && (sec
->flags
& SEC_ALLOC
) != 0)
2846 struct elf_dyn_relocs
*p
;
2847 struct elf_dyn_relocs
**head
;
2849 /* We must copy these reloc types into the output file.
2850 Create a reloc section in dynobj and make room for
2854 if (htab
->elf
.dynobj
== NULL
)
2855 htab
->elf
.dynobj
= abfd
;
2857 sreloc
= _bfd_elf_make_dynamic_reloc_section
2858 (sec
, htab
->elf
.dynobj
, 2, abfd
, /*rela? */ true);
2864 /* If this is a global symbol, we count the number of
2865 relocations we need for this symbol. */
2868 head
= &h
->dyn_relocs
;
2872 /* Track dynamic relocs needed for local syms too.
2873 We really need local syms available to do this
2878 s
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
2882 vpp
= &elf_section_data (s
)->local_dynrel
;
2883 head
= (struct elf_dyn_relocs
**)vpp
;
2887 if (p
== NULL
|| p
->sec
!= sec
)
2889 size_t amt
= sizeof *p
;
2890 p
= bfd_alloc (htab
->elf
.dynobj
, amt
);
2901 if (r_type
== R_C6000_DSBT_INDEX
)
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
:
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",
2924 bfd_und_section_ptr
, 0,
2925 NULL
, false, false, &bh
))
2927 ((struct elf_link_hash_entry
*) bh
)->non_elf
= 0;
2929 if (h
!= NULL
&& bfd_link_executable (info
))
2931 /* For B14-relative addresses, we might need a copy
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
,
2954 switch (sym
->st_shndx
)
2956 case SHN_TIC6X_SCOMMON
:
2957 *secp
= bfd_make_section_old_way (abfd
, ".scommon");
2958 (*secp
)->flags
|= SEC_IS_COMMON
| SEC_SMALL_DATA
;
2959 *valp
= sym
->st_size
;
2960 bfd_set_section_alignment (*secp
, bfd_log2 (sym
->st_value
));
2968 elf32_tic6x_symbol_processing (bfd
*abfd ATTRIBUTE_UNUSED
, asymbol
*asym
)
2970 elf_symbol_type
*elfsym
;
2972 elfsym
= (elf_symbol_type
*) asym
;
2973 switch (elfsym
->internal_elf_sym
.st_shndx
)
2975 case SHN_TIC6X_SCOMMON
:
2976 asym
->section
= &tic6x_elf_scom_section
;
2977 asym
->value
= elfsym
->internal_elf_sym
.st_size
;
2983 elf32_tic6x_link_output_symbol_hook (struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
2984 const char *name ATTRIBUTE_UNUSED
,
2985 Elf_Internal_Sym
*sym
,
2986 asection
*input_sec
,
2987 struct elf_link_hash_entry
*h ATTRIBUTE_UNUSED
)
2989 /* If we see a common symbol, which implies a relocatable link, then
2990 if a symbol was small common in an input file, mark it as small
2991 common in the output file. */
2992 if (sym
->st_shndx
== SHN_COMMON
&& strcmp (input_sec
->name
, ".scommon") == 0)
2993 sym
->st_shndx
= SHN_TIC6X_SCOMMON
;
2999 elf32_tic6x_section_from_bfd_section (bfd
*abfd ATTRIBUTE_UNUSED
,
3003 if (strcmp (bfd_section_name (sec
), ".scommon") == 0)
3005 *retval
= SHN_TIC6X_SCOMMON
;
3012 /* Allocate space in .plt, .got and associated reloc sections for
3016 elf32_tic6x_allocate_dynrelocs (struct elf_link_hash_entry
*h
, void *inf
)
3018 struct bfd_link_info
*info
;
3019 struct elf32_tic6x_link_hash_table
*htab
;
3020 struct elf_dyn_relocs
*p
;
3022 if (h
->root
.type
== bfd_link_hash_indirect
)
3025 info
= (struct bfd_link_info
*) inf
;
3026 htab
= elf32_tic6x_hash_table (info
);
3028 if (htab
->elf
.dynamic_sections_created
&& h
->plt
.refcount
> 0)
3030 /* Make sure this symbol is output as a dynamic symbol.
3031 Undefined weak syms won't yet be marked as dynamic. */
3032 if (h
->dynindx
== -1 && !h
->forced_local
)
3034 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
3038 if (bfd_link_pic (info
)
3039 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h
))
3041 asection
*s
= htab
->elf
.splt
;
3043 /* If this is the first .plt entry, make room for the special
3046 s
->size
+= PLT_ENTRY_SIZE
;
3048 h
->plt
.offset
= s
->size
;
3050 /* If this symbol is not defined in a regular file, and we are
3051 not generating a shared library, then set the symbol to this
3052 location in the .plt. This is required to make function
3053 pointers compare as equal between the normal executable and
3054 the shared library. */
3055 if (! bfd_link_pic (info
) && !h
->def_regular
)
3057 h
->root
.u
.def
.section
= s
;
3058 h
->root
.u
.def
.value
= h
->plt
.offset
;
3061 /* Make room for this entry. */
3062 s
->size
+= PLT_ENTRY_SIZE
;
3063 /* We also need to make an entry in the .got.plt section, which
3064 will be placed in the .got section by the linker script. */
3065 htab
->elf
.sgotplt
->size
+= 4;
3066 /* We also need to make an entry in the .rel.plt section. */
3067 htab
->elf
.srelplt
->size
+= sizeof (Elf32_External_Rela
);
3071 h
->plt
.offset
= (bfd_vma
) -1;
3077 h
->plt
.offset
= (bfd_vma
) -1;
3081 if (h
->got
.refcount
> 0)
3085 /* Make sure this symbol is output as a dynamic symbol.
3086 Undefined weak syms won't yet be marked as dynamic. */
3087 if (h
->dynindx
== -1
3088 && !h
->forced_local
)
3090 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
3095 h
->got
.offset
= s
->size
;
3098 if (!(ELF_ST_VISIBILITY (h
->other
)
3099 && h
->root
.type
== bfd_link_hash_undefweak
))
3100 htab
->elf
.srelgot
->size
+= sizeof (Elf32_External_Rela
);
3103 h
->got
.offset
= (bfd_vma
) -1;
3105 if (h
->dyn_relocs
== NULL
)
3108 /* Discard relocs on undefined weak syms with non-default
3110 if (bfd_link_pic (info
) || elf32_tic6x_using_dsbt (htab
->obfd
))
3112 /* We use the pc_count field to hold the number of
3113 R_C6000_DSBT_INDEX relocs. */
3114 if (htab
->params
.dsbt_index
!= 0)
3116 struct elf_dyn_relocs
**pp
;
3118 for (pp
= &h
->dyn_relocs
; (p
= *pp
) != NULL
; )
3120 p
->count
-= p
->pc_count
;
3129 if (h
->dyn_relocs
!= NULL
3130 && h
->root
.type
== bfd_link_hash_undefweak
)
3132 if (ELF_ST_VISIBILITY (h
->other
) != STV_DEFAULT
)
3133 h
->dyn_relocs
= NULL
;
3135 /* Make sure undefined weak symbols are output as a dynamic
3137 else if (h
->dynindx
== -1
3138 && !h
->forced_local
)
3140 if (! bfd_elf_link_record_dynamic_symbol (info
, h
))
3146 /* Finally, allocate space. */
3147 for (p
= h
->dyn_relocs
; p
!= NULL
; p
= p
->next
)
3151 sreloc
= elf_section_data (p
->sec
)->sreloc
;
3153 BFD_ASSERT (sreloc
!= NULL
);
3154 sreloc
->size
+= p
->count
* sizeof (Elf32_External_Rela
);
3160 /* Set the sizes of the dynamic sections. */
3163 elf32_tic6x_size_dynamic_sections (bfd
*output_bfd
, struct bfd_link_info
*info
)
3165 struct elf32_tic6x_link_hash_table
*htab
;
3171 htab
= elf32_tic6x_hash_table (info
);
3172 dynobj
= htab
->elf
.dynobj
;
3176 if (htab
->elf
.dynamic_sections_created
)
3178 /* Set the contents of the .interp section to the interpreter. */
3179 if (bfd_link_executable (info
) && !info
->nointerp
)
3181 s
= bfd_get_linker_section (dynobj
, ".interp");
3184 s
->size
= sizeof ELF_DYNAMIC_INTERPRETER
;
3185 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
3189 /* Set up .got offsets for local syms, and space for local dynamic
3191 for (ibfd
= info
->input_bfds
; ibfd
!= NULL
; ibfd
= ibfd
->link
.next
)
3193 bfd_signed_vma
*local_got
;
3194 bfd_signed_vma
*end_local_got
;
3195 bfd_size_type locsymcount
;
3196 Elf_Internal_Shdr
*symtab_hdr
;
3199 for (s
= ibfd
->sections
; s
!= NULL
; s
= s
->next
)
3201 struct elf_dyn_relocs
*p
;
3203 for (p
= ((struct elf_dyn_relocs
*)
3204 elf_section_data (s
)->local_dynrel
);
3208 if (!bfd_is_abs_section (p
->sec
)
3209 && bfd_is_abs_section (p
->sec
->output_section
))
3211 /* Input section has been discarded, either because
3212 it is a copy of a linkonce section or due to
3213 linker script /DISCARD/, so we'll be discarding
3216 else if (p
->count
!= 0)
3218 srel
= elf_section_data (p
->sec
)->sreloc
;
3219 srel
->size
+= p
->count
* sizeof (Elf32_External_Rela
);
3220 if ((p
->sec
->output_section
->flags
& SEC_READONLY
) != 0)
3221 info
->flags
|= DF_TEXTREL
;
3226 local_got
= elf_local_got_refcounts (ibfd
);
3230 symtab_hdr
= &elf_symtab_hdr (ibfd
);
3231 locsymcount
= symtab_hdr
->sh_info
;
3232 end_local_got
= local_got
+ locsymcount
;
3234 srel
= htab
->elf
.srelgot
;
3235 for (; local_got
< end_local_got
; ++local_got
)
3239 *local_got
= s
->size
;
3242 if (bfd_link_pic (info
) || elf32_tic6x_using_dsbt (output_bfd
))
3244 srel
->size
+= sizeof (Elf32_External_Rela
);
3248 *local_got
= (bfd_vma
) -1;
3252 /* Allocate global sym .plt and .got entries, and space for global
3253 sym dynamic relocs. */
3254 elf_link_hash_traverse (&htab
->elf
, elf32_tic6x_allocate_dynrelocs
, info
);
3256 /* We now have determined the sizes of the various dynamic sections.
3257 Allocate memory for them. */
3259 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
3261 bool strip_section
= true;
3263 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
3266 if (s
== htab
->dsbt
)
3267 s
->size
= 4 * htab
->params
.dsbt_size
;
3268 else if (s
== htab
->elf
.splt
3269 || s
== htab
->elf
.sgot
3270 || s
== htab
->elf
.sgotplt
3271 || s
== htab
->elf
.sdynbss
3272 || s
== htab
->elf
.sdynrelro
)
3274 /* Strip this section if we don't need it; see the
3276 /* We'd like to strip these sections if they aren't needed, but if
3277 we've exported dynamic symbols from them we must leave them.
3278 It's too late to tell BFD to get rid of the symbols. */
3280 if (htab
->elf
.hplt
!= NULL
)
3281 strip_section
= false;
3283 /* Round up the size of the PLT section to a multiple of 32. */
3284 if (s
== htab
->elf
.splt
&& s
->size
> 0)
3285 s
->size
= (s
->size
+ 31) & ~(bfd_vma
)31;
3287 else if (startswith (bfd_section_name (s
), ".rela"))
3290 && s
!= htab
->elf
.srelplt
)
3293 /* We use the reloc_count field as a counter if we need
3294 to copy relocs into the output file. */
3299 /* It's not one of our sections, so don't allocate space. */
3305 /* If we don't need this section, strip it from the
3306 output file. This is mostly to handle .rel.bss and
3307 .rel.plt. We must create both sections in
3308 create_dynamic_sections, because they must be created
3309 before the linker maps input sections to output
3310 sections. The linker does that before
3311 adjust_dynamic_symbol is called, and it is that
3312 function which decides whether anything needs to go
3313 into these sections. */
3315 s
->flags
|= SEC_EXCLUDE
;
3319 if ((s
->flags
& SEC_HAS_CONTENTS
) == 0)
3322 /* Allocate memory for the section contents. We use bfd_zalloc
3323 here in case unused entries are not reclaimed before the
3324 section's contents are written out. This should not happen,
3325 but this way if it does, we get a R_C6000_NONE reloc instead
3327 s
->contents
= bfd_zalloc (dynobj
, s
->size
);
3328 if (s
->contents
== NULL
)
3332 if (htab
->elf
.dynamic_sections_created
)
3334 /* Add some entries to the .dynamic section. We fill in the
3335 values later, in elf32_tic6x_finish_dynamic_sections, but we
3336 must add the entries now so that we get the correct size for
3337 the .dynamic section. The DT_DEBUG entry is filled in by the
3338 dynamic linker and used by the debugger. */
3339 #define add_dynamic_entry(TAG, VAL) \
3340 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
3342 if (!_bfd_elf_add_dynamic_tags (output_bfd
, info
, relocs
))
3345 if (!add_dynamic_entry (DT_C6000_DSBT_BASE
, 0)
3346 || !add_dynamic_entry (DT_C6000_DSBT_SIZE
, htab
->params
.dsbt_size
)
3347 || !add_dynamic_entry (DT_C6000_DSBT_INDEX
,
3348 htab
->params
.dsbt_index
))
3352 #undef add_dynamic_entry
3357 /* This function is called after all the input files have been read,
3358 and the input sections have been assigned to output sections. */
3361 elf32_tic6x_always_size_sections (bfd
*output_bfd
, struct bfd_link_info
*info
)
3363 if (elf32_tic6x_using_dsbt (output_bfd
) && !bfd_link_relocatable (info
)
3364 && !bfd_elf_stack_segment_size (output_bfd
, info
,
3365 "__stacksize", DEFAULT_STACK_SIZE
))
3372 elf32_tic6x_finish_dynamic_sections (bfd
*output_bfd ATTRIBUTE_UNUSED
,
3373 struct bfd_link_info
*info
)
3375 struct elf32_tic6x_link_hash_table
*htab
;
3379 htab
= elf32_tic6x_hash_table (info
);
3380 dynobj
= htab
->elf
.dynobj
;
3381 sdyn
= bfd_get_linker_section (dynobj
, ".dynamic");
3383 if (elf_hash_table (info
)->dynamic_sections_created
)
3385 Elf32_External_Dyn
* dyncon
;
3386 Elf32_External_Dyn
* dynconend
;
3388 BFD_ASSERT (sdyn
!= NULL
);
3390 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
3391 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->size
);
3393 for (; dyncon
< dynconend
; dyncon
++)
3395 Elf_Internal_Dyn dyn
;
3398 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
3405 case DT_C6000_DSBT_BASE
:
3407 dyn
.d_un
.d_ptr
= (s
->output_section
->vma
+ s
->output_offset
);
3411 s
= htab
->elf
.sgotplt
;
3412 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
3416 s
= htab
->elf
.srelplt
;
3417 dyn
.d_un
.d_ptr
= s
->output_section
->vma
+ s
->output_offset
;
3421 s
= htab
->elf
.srelplt
;
3422 dyn
.d_un
.d_val
= s
->size
;
3425 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
3428 /* Fill in the first entry in the procedure linkage table. */
3429 if (htab
->elf
.splt
&& htab
->elf
.splt
->size
> 0)
3431 bfd_vma got_offs
= (htab
->elf
.sgotplt
->output_section
->vma
3432 + htab
->elf
.sgotplt
->output_offset
3433 - htab
->dsbt
->output_section
->vma
3434 - htab
->dsbt
->output_offset
) / 4;
3436 /* ldw .D2T2 *+b14[$GOT(0)],b2 */
3437 bfd_put_32 (output_bfd
, got_offs
<< 8 | 0x0100006e,
3438 htab
->elf
.splt
->contents
);
3439 /* ldw .D2T2 *+b14[$GOT(4)],b1 */
3440 bfd_put_32 (output_bfd
, (got_offs
+ 1) << 8 | 0x0080006e,
3441 htab
->elf
.splt
->contents
+ 4);
3443 bfd_put_32 (output_bfd
, 0x00004000,
3444 htab
->elf
.splt
->contents
+ 8);
3446 bfd_put_32 (output_bfd
, 0x00080362,
3447 htab
->elf
.splt
->contents
+ 12);
3449 bfd_put_32 (output_bfd
, 0x00008000,
3450 htab
->elf
.splt
->contents
+ 16);
3452 elf_section_data (htab
->elf
.splt
->output_section
)
3453 ->this_hdr
.sh_entsize
= PLT_ENTRY_SIZE
;
3460 /* Return address for Ith PLT stub in section PLT, for relocation REL
3461 or (bfd_vma) -1 if it should not be included. */
3464 elf32_tic6x_plt_sym_val (bfd_vma i
, const asection
*plt
,
3465 const arelent
*rel ATTRIBUTE_UNUSED
)
3467 return plt
->vma
+ (i
+ 1) * PLT_ENTRY_SIZE
;
3471 elf32_tic6x_obj_attrs_arg_type (int tag
)
3473 if (tag
== Tag_ABI_compatibility
)
3474 return ATTR_TYPE_FLAG_INT_VAL
| ATTR_TYPE_FLAG_STR_VAL
;
3476 return ATTR_TYPE_FLAG_STR_VAL
;
3478 return ATTR_TYPE_FLAG_INT_VAL
;
3482 elf32_tic6x_obj_attrs_order (int num
)
3484 if (num
== LEAST_KNOWN_OBJ_ATTRIBUTE
)
3485 return Tag_ABI_conformance
;
3486 if ((num
- 1) < Tag_ABI_conformance
)
3492 elf32_tic6x_obj_attrs_handle_unknown (bfd
*abfd
, int tag
)
3494 if ((tag
& 127) < 64)
3497 /* xgettext:c-format */
3498 (_("%pB: error: unknown mandatory EABI object attribute %d"),
3500 bfd_set_error (bfd_error_bad_value
);
3506 /* xgettext:c-format */
3507 (_("%pB: warning: unknown EABI object attribute %d"),
3513 /* Merge the Tag_ISA attribute values ARCH1 and ARCH2
3514 and return the merged value. At present, all merges succeed, so no
3515 return value for errors is defined. */
3518 elf32_tic6x_merge_arch_attributes (int arch1
, int arch2
)
3520 int min_arch
, max_arch
;
3522 min_arch
= (arch1
< arch2
? arch1
: arch2
);
3523 max_arch
= (arch1
> arch2
? arch1
: arch2
);
3525 /* In most cases, the numerically greatest value is the correct
3526 merged value, but merging C64 and C67 results in C674X. */
3527 if ((min_arch
== C6XABI_Tag_ISA_C67X
3528 || min_arch
== C6XABI_Tag_ISA_C67XP
)
3529 && (max_arch
== C6XABI_Tag_ISA_C64X
3530 || max_arch
== C6XABI_Tag_ISA_C64XP
))
3531 return C6XABI_Tag_ISA_C674X
;
3536 /* Convert a Tag_ABI_array_object_alignment or
3537 Tag_ABI_array_object_align_expected tag value TAG to a
3538 corresponding alignment value; return the alignment, or -1 for an
3539 unknown tag value. */
3542 elf32_tic6x_tag_to_array_alignment (int tag
)
3560 /* Convert a Tag_ABI_array_object_alignment or
3561 Tag_ABI_array_object_align_expected alignment ALIGN to a
3562 corresponding tag value; return the tag value. */
3565 elf32_tic6x_array_alignment_to_tag (int align
)
3583 /* Merge attributes from IBFD and OBFD, returning TRUE if the merge
3584 succeeded, FALSE otherwise. */
3587 elf32_tic6x_merge_attributes (bfd
*ibfd
, struct bfd_link_info
*info
)
3589 bfd
*obfd
= info
->output_bfd
;
3591 obj_attribute
*in_attr
;
3592 obj_attribute
*out_attr
;
3594 int array_align_in
, array_align_out
, array_expect_in
, array_expect_out
;
3596 /* FIXME: What should be checked when linking shared libraries? */
3597 if ((ibfd
->flags
& DYNAMIC
) != 0)
3600 if (!elf_known_obj_attributes_proc (obfd
)[0].i
)
3602 /* This is the first object. Copy the attributes. */
3603 _bfd_elf_copy_obj_attributes (ibfd
, obfd
);
3605 out_attr
= elf_known_obj_attributes_proc (obfd
);
3607 /* Use the Tag_null value to indicate the attributes have been
3614 in_attr
= elf_known_obj_attributes_proc (ibfd
);
3615 out_attr
= elf_known_obj_attributes_proc (obfd
);
3617 /* No specification yet for handling of unknown attributes, so just
3618 ignore them and handle known ones. */
3620 if (out_attr
[Tag_ABI_stack_align_preserved
].i
3621 < in_attr
[Tag_ABI_stack_align_needed
].i
)
3624 /* xgettext:c-format */
3625 (_("error: %pB requires more stack alignment than %pB preserves"),
3629 if (in_attr
[Tag_ABI_stack_align_preserved
].i
3630 < out_attr
[Tag_ABI_stack_align_needed
].i
)
3633 /* xgettext:c-format */
3634 (_("error: %pB requires more stack alignment than %pB preserves"),
3639 array_align_in
= elf32_tic6x_tag_to_array_alignment
3640 (in_attr
[Tag_ABI_array_object_alignment
].i
);
3641 if (array_align_in
== -1)
3644 (_("error: unknown Tag_ABI_array_object_alignment value in %pB"),
3648 array_align_out
= elf32_tic6x_tag_to_array_alignment
3649 (out_attr
[Tag_ABI_array_object_alignment
].i
);
3650 if (array_align_out
== -1)
3653 (_("error: unknown Tag_ABI_array_object_alignment value in %pB"),
3657 array_expect_in
= elf32_tic6x_tag_to_array_alignment
3658 (in_attr
[Tag_ABI_array_object_align_expected
].i
);
3659 if (array_expect_in
== -1)
3662 (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"),
3666 array_expect_out
= elf32_tic6x_tag_to_array_alignment
3667 (out_attr
[Tag_ABI_array_object_align_expected
].i
);
3668 if (array_expect_out
== -1)
3671 (_("error: unknown Tag_ABI_array_object_align_expected value in %pB"),
3676 if (array_align_out
< array_expect_in
)
3679 /* xgettext:c-format */
3680 (_("error: %pB requires more array alignment than %pB preserves"),
3684 if (array_align_in
< array_expect_out
)
3687 /* xgettext:c-format */
3688 (_("error: %pB requires more array alignment than %pB preserves"),
3693 for (i
= LEAST_KNOWN_OBJ_ATTRIBUTE
; i
< NUM_KNOWN_OBJ_ATTRIBUTES
; i
++)
3698 out_attr
[i
].i
= elf32_tic6x_merge_arch_attributes (in_attr
[i
].i
,
3702 case Tag_ABI_wchar_t
:
3703 if (out_attr
[i
].i
== 0)
3704 out_attr
[i
].i
= in_attr
[i
].i
;
3705 if (out_attr
[i
].i
!= 0
3706 && in_attr
[i
].i
!= 0
3707 && out_attr
[i
].i
!= in_attr
[i
].i
)
3710 /* xgettext:c-format */
3711 (_("warning: %pB and %pB differ in wchar_t size"), obfd
, ibfd
);
3715 case Tag_ABI_stack_align_needed
:
3716 if (out_attr
[i
].i
< in_attr
[i
].i
)
3717 out_attr
[i
].i
= in_attr
[i
].i
;
3720 case Tag_ABI_stack_align_preserved
:
3721 if (out_attr
[i
].i
> in_attr
[i
].i
)
3722 out_attr
[i
].i
= in_attr
[i
].i
;
3726 if (out_attr
[i
].i
!= in_attr
[i
].i
)
3729 /* xgettext:c-format */
3730 (_("warning: %pB and %pB differ in whether code is "
3731 "compiled for DSBT"),
3738 /* Don't transfer these tags from dynamic objects. */
3739 if ((ibfd
->flags
& DYNAMIC
) != 0)
3741 if (out_attr
[i
].i
> in_attr
[i
].i
)
3742 out_attr
[i
].i
= in_attr
[i
].i
;
3745 case Tag_ABI_array_object_alignment
:
3746 if (array_align_out
!= -1
3747 && array_align_in
!= -1
3748 && array_align_out
> array_align_in
)
3750 = elf32_tic6x_array_alignment_to_tag (array_align_in
);
3753 case Tag_ABI_array_object_align_expected
:
3754 if (array_expect_out
!= -1
3755 && array_expect_in
!= -1
3756 && array_expect_out
< array_expect_in
)
3758 = elf32_tic6x_array_alignment_to_tag (array_expect_in
);
3761 case Tag_ABI_conformance
:
3762 /* Merging for this attribute is not specified. As on ARM,
3763 treat a missing attribute as no claim to conform and only
3764 merge identical values. */
3765 if (out_attr
[i
].s
== NULL
3766 || in_attr
[i
].s
== NULL
3767 || strcmp (out_attr
[i
].s
,
3769 out_attr
[i
].s
= NULL
;
3772 case Tag_ABI_compatibility
:
3773 /* Merged in _bfd_elf_merge_object_attributes. */
3778 = result
&& _bfd_elf_merge_unknown_attribute_low (ibfd
, obfd
, i
);
3782 if (in_attr
[i
].type
&& !out_attr
[i
].type
)
3783 out_attr
[i
].type
= in_attr
[i
].type
;
3786 /* Merge Tag_ABI_compatibility attributes and any common GNU ones. */
3787 if (!_bfd_elf_merge_object_attributes (ibfd
, info
))
3790 result
&= _bfd_elf_merge_unknown_attribute_list (ibfd
, obfd
);
3796 elf32_tic6x_merge_private_bfd_data (bfd
*ibfd
, struct bfd_link_info
*info
)
3798 if (!_bfd_generic_verify_endian_match (ibfd
, info
))
3801 if (! is_tic6x_elf (ibfd
) || ! is_tic6x_elf (info
->output_bfd
))
3804 if (!elf32_tic6x_merge_attributes (ibfd
, info
))
3810 /* Add a new unwind edit to the list described by HEAD, TAIL. If TINDEX is zero,
3811 adds the edit to the start of the list. (The list must be built in order of
3812 ascending TINDEX: the function's callers are primarily responsible for
3813 maintaining that condition). */
3816 elf32_tic6x_add_unwind_table_edit (tic6x_unwind_table_edit
**head
,
3817 tic6x_unwind_table_edit
**tail
,
3818 tic6x_unwind_edit_type type
,
3819 asection
*linked_section
,
3820 unsigned int tindex
)
3822 tic6x_unwind_table_edit
*new_edit
= (tic6x_unwind_table_edit
*)
3823 xmalloc (sizeof (tic6x_unwind_table_edit
));
3825 new_edit
->type
= type
;
3826 new_edit
->linked_section
= linked_section
;
3827 new_edit
->index
= tindex
;
3831 new_edit
->next
= NULL
;
3834 (*tail
)->next
= new_edit
;
3843 new_edit
->next
= *head
;
3852 static _tic6x_elf_section_data
*
3853 get_tic6x_elf_section_data (asection
* sec
)
3855 if (sec
&& sec
->owner
&& is_tic6x_elf (sec
->owner
))
3856 return elf32_tic6x_section_data (sec
);
3862 /* Increase the size of EXIDX_SEC by ADJUST bytes. ADJUST must be negative. */
3864 elf32_tic6x_adjust_exidx_size (asection
*exidx_sec
, int adjust
)
3868 if (!exidx_sec
->rawsize
)
3869 exidx_sec
->rawsize
= exidx_sec
->size
;
3871 bfd_set_section_size (exidx_sec
, exidx_sec
->size
+ adjust
);
3872 out_sec
= exidx_sec
->output_section
;
3873 /* Adjust size of output section. */
3874 bfd_set_section_size (out_sec
, out_sec
->size
+adjust
);
3877 /* Insert an EXIDX_CANTUNWIND marker at the end of a section. */
3879 elf32_tic6x_insert_cantunwind_after (asection
*text_sec
, asection
*exidx_sec
)
3881 struct _tic6x_elf_section_data
*exidx_data
;
3883 exidx_data
= get_tic6x_elf_section_data (exidx_sec
);
3884 elf32_tic6x_add_unwind_table_edit (
3885 &exidx_data
->u
.exidx
.unwind_edit_list
,
3886 &exidx_data
->u
.exidx
.unwind_edit_tail
,
3887 INSERT_EXIDX_CANTUNWIND_AT_END
, text_sec
, UINT_MAX
);
3889 elf32_tic6x_adjust_exidx_size (exidx_sec
, 8);
3892 /* Scan .cx6abi.exidx tables, and create a list describing edits which
3893 should be made to those tables, such that:
3895 1. Regions without unwind data are marked with EXIDX_CANTUNWIND entries.
3896 2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind
3897 codes which have been inlined into the index).
3899 If MERGE_EXIDX_ENTRIES is false, duplicate entries are not merged.
3901 The edits are applied when the tables are written
3902 (in elf32_tic6x_write_section).
3906 elf32_tic6x_fix_exidx_coverage (asection
**text_section_order
,
3907 unsigned int num_text_sections
,
3908 struct bfd_link_info
*info
,
3909 bool merge_exidx_entries
)
3912 unsigned int last_second_word
= 0, i
;
3913 asection
*last_exidx_sec
= NULL
;
3914 asection
*last_text_sec
= NULL
;
3915 int last_unwind_type
= -1;
3917 /* Walk over all EXIDX sections, and create backlinks from the corrsponding
3919 for (inp
= info
->input_bfds
; inp
!= NULL
; inp
= inp
->link
.next
)
3923 for (sec
= inp
->sections
; sec
!= NULL
; sec
= sec
->next
)
3925 struct bfd_elf_section_data
*elf_sec
= elf_section_data (sec
);
3926 Elf_Internal_Shdr
*hdr
= &elf_sec
->this_hdr
;
3928 if (!hdr
|| hdr
->sh_type
!= SHT_C6000_UNWIND
)
3931 if (elf_sec
->linked_to
)
3933 Elf_Internal_Shdr
*linked_hdr
3934 = &elf_section_data (elf_sec
->linked_to
)->this_hdr
;
3935 struct _tic6x_elf_section_data
*linked_sec_tic6x_data
3936 = get_tic6x_elf_section_data (linked_hdr
->bfd_section
);
3938 if (linked_sec_tic6x_data
== NULL
)
3941 /* Link this .c6xabi.exidx section back from the
3942 text section it describes. */
3943 linked_sec_tic6x_data
->u
.text
.tic6x_exidx_sec
= sec
;
3948 /* Walk all text sections in order of increasing VMA. Eilminate duplicate
3949 index table entries (EXIDX_CANTUNWIND and inlined unwind opcodes),
3950 and add EXIDX_CANTUNWIND entries for sections with no unwind table data. */
3952 for (i
= 0; i
< num_text_sections
; i
++)
3954 asection
*sec
= text_section_order
[i
];
3955 asection
*exidx_sec
;
3956 struct _tic6x_elf_section_data
*tic6x_data
3957 = get_tic6x_elf_section_data (sec
);
3958 struct _tic6x_elf_section_data
*exidx_data
;
3959 bfd_byte
*contents
= NULL
;
3960 int deleted_exidx_bytes
= 0;
3962 tic6x_unwind_table_edit
*unwind_edit_head
= NULL
;
3963 tic6x_unwind_table_edit
*unwind_edit_tail
= NULL
;
3964 Elf_Internal_Shdr
*hdr
;
3967 if (tic6x_data
== NULL
)
3970 exidx_sec
= tic6x_data
->u
.text
.tic6x_exidx_sec
;
3971 if (exidx_sec
== NULL
)
3973 /* Section has no unwind data. */
3974 if (last_unwind_type
== 0 || !last_exidx_sec
)
3977 /* Ignore zero sized sections. */
3981 elf32_tic6x_insert_cantunwind_after (last_text_sec
, last_exidx_sec
);
3982 last_unwind_type
= 0;
3986 /* Skip /DISCARD/ sections. */
3987 if (bfd_is_abs_section (exidx_sec
->output_section
))
3990 hdr
= &elf_section_data (exidx_sec
)->this_hdr
;
3991 if (hdr
->sh_type
!= SHT_C6000_UNWIND
)
3994 exidx_data
= get_tic6x_elf_section_data (exidx_sec
);
3995 if (exidx_data
== NULL
)
3998 ibfd
= exidx_sec
->owner
;
4000 if (hdr
->contents
!= NULL
)
4001 contents
= hdr
->contents
;
4002 else if (! bfd_malloc_and_get_section (ibfd
, exidx_sec
, &contents
))
4006 for (j
= 0; j
< hdr
->sh_size
; j
+= 8)
4008 unsigned int second_word
= bfd_get_32 (ibfd
, contents
+ j
+ 4);
4012 /* An EXIDX_CANTUNWIND entry. */
4013 if (second_word
== 1)
4015 if (last_unwind_type
== 0)
4019 /* Inlined unwinding data. Merge if equal to previous. */
4020 else if ((second_word
& 0x80000000) != 0)
4022 if (merge_exidx_entries
4023 && last_second_word
== second_word
4024 && last_unwind_type
== 1)
4027 last_second_word
= second_word
;
4029 /* Normal table entry. In theory we could merge these too,
4030 but duplicate entries are likely to be much less common. */
4036 elf32_tic6x_add_unwind_table_edit (&unwind_edit_head
,
4037 &unwind_edit_tail
, DELETE_EXIDX_ENTRY
, NULL
, j
/ 8);
4039 deleted_exidx_bytes
+= 8;
4042 last_unwind_type
= unwind_type
;
4045 /* Free contents if we allocated it ourselves. */
4046 if (contents
!= hdr
->contents
)
4049 /* Record edits to be applied later (in elf32_tic6x_write_section). */
4050 exidx_data
->u
.exidx
.unwind_edit_list
= unwind_edit_head
;
4051 exidx_data
->u
.exidx
.unwind_edit_tail
= unwind_edit_tail
;
4053 if (deleted_exidx_bytes
> 0)
4054 elf32_tic6x_adjust_exidx_size (exidx_sec
, -deleted_exidx_bytes
);
4056 last_exidx_sec
= exidx_sec
;
4057 last_text_sec
= sec
;
4060 /* Add terminating CANTUNWIND entry. */
4061 if (last_exidx_sec
&& last_unwind_type
!= 0)
4062 elf32_tic6x_insert_cantunwind_after (last_text_sec
, last_exidx_sec
);
4067 /* Add ADDEND to lower 31 bits of VAL, leaving other bits unmodified. */
4069 static unsigned long
4070 elf32_tic6x_add_low31 (unsigned long val
, bfd_vma addend
)
4072 return (val
& ~0x7ffffffful
) | ((val
+ addend
) & 0x7ffffffful
);
4075 /* Copy an .c6xabi.exidx table entry, adding OFFSET to (applied) PREL31
4076 relocations. OFFSET is in bytes, and will be scaled before encoding. */
4080 elf32_tic6x_copy_exidx_entry (bfd
*output_bfd
, bfd_byte
*to
, bfd_byte
*from
,
4083 unsigned long first_word
= bfd_get_32 (output_bfd
, from
);
4084 unsigned long second_word
= bfd_get_32 (output_bfd
, from
+ 4);
4087 /* High bit of first word is supposed to be zero. */
4088 if ((first_word
& 0x80000000ul
) == 0)
4089 first_word
= elf32_tic6x_add_low31 (first_word
, offset
);
4091 /* If the high bit of the first word is clear, and the bit pattern is not 0x1
4092 (EXIDX_CANTUNWIND), this is an offset to an .c6xabi.extab entry. */
4093 if ((second_word
!= 0x1) && ((second_word
& 0x80000000ul
) == 0))
4094 second_word
= elf32_tic6x_add_low31 (second_word
, offset
);
4096 bfd_put_32 (output_bfd
, first_word
, to
);
4097 bfd_put_32 (output_bfd
, second_word
, to
+ 4);
4100 /* Do the actual mangling of exception index tables. */
4103 elf32_tic6x_write_section (bfd
*output_bfd
,
4104 struct bfd_link_info
*link_info
,
4108 _tic6x_elf_section_data
*tic6x_data
;
4109 struct elf32_tic6x_link_hash_table
*globals
4110 = elf32_tic6x_hash_table (link_info
);
4111 bfd_vma offset
= sec
->output_section
->vma
+ sec
->output_offset
;
4113 if (globals
== NULL
)
4116 /* If this section has not been allocated an _tic6x_elf_section_data
4117 structure then we cannot record anything. */
4118 tic6x_data
= get_tic6x_elf_section_data (sec
);
4119 if (tic6x_data
== NULL
)
4122 if (tic6x_data
->elf
.this_hdr
.sh_type
!= SHT_C6000_UNWIND
)
4125 tic6x_unwind_table_edit
*edit_node
4126 = tic6x_data
->u
.exidx
.unwind_edit_list
;
4127 /* Now, sec->size is the size of the section we will write. The original
4128 size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND
4129 markers) was sec->rawsize. (This isn't the case if we perform no
4130 edits, then rawsize will be zero and we should use size). */
4131 bfd_byte
*edited_contents
= (bfd_byte
*) bfd_malloc (sec
->size
);
4132 unsigned int input_size
= sec
->rawsize
? sec
->rawsize
: sec
->size
;
4133 unsigned int in_index
, out_index
;
4134 bfd_vma add_to_offsets
= 0;
4136 for (in_index
= 0, out_index
= 0; in_index
* 8 < input_size
|| edit_node
;)
4140 unsigned int edit_index
= edit_node
->index
;
4142 if (in_index
< edit_index
&& in_index
* 8 < input_size
)
4144 elf32_tic6x_copy_exidx_entry (output_bfd
,
4145 edited_contents
+ out_index
* 8,
4146 contents
+ in_index
* 8, add_to_offsets
);
4150 else if (in_index
== edit_index
4151 || (in_index
* 8 >= input_size
4152 && edit_index
== UINT_MAX
))
4154 switch (edit_node
->type
)
4156 case DELETE_EXIDX_ENTRY
:
4158 add_to_offsets
+= 8;
4161 case INSERT_EXIDX_CANTUNWIND_AT_END
:
4163 asection
*text_sec
= edit_node
->linked_section
;
4164 bfd_vma text_offset
= text_sec
->output_section
->vma
4165 + text_sec
->output_offset
4167 bfd_vma exidx_offset
= offset
+ out_index
* 8;
4168 unsigned long prel31_offset
;
4170 /* Note: this is meant to be equivalent to an
4171 R_C6000_PREL31 relocation. These synthetic
4172 EXIDX_CANTUNWIND markers are not relocated by the
4173 usual BFD method. */
4174 prel31_offset
= ((text_offset
- exidx_offset
) >> 1)
4177 /* First address we can't unwind. */
4178 bfd_put_32 (output_bfd
, prel31_offset
,
4179 &edited_contents
[out_index
* 8]);
4181 /* Code for EXIDX_CANTUNWIND. */
4182 bfd_put_32 (output_bfd
, 0x1,
4183 &edited_contents
[out_index
* 8 + 4]);
4186 add_to_offsets
-= 8;
4191 edit_node
= edit_node
->next
;
4196 /* No more edits, copy remaining entries verbatim. */
4197 elf32_tic6x_copy_exidx_entry (output_bfd
,
4198 edited_contents
+ out_index
* 8,
4199 contents
+ in_index
* 8, add_to_offsets
);
4205 if (!(sec
->flags
& SEC_EXCLUDE
) && !(sec
->flags
& SEC_NEVER_LOAD
))
4206 bfd_set_section_contents (output_bfd
, sec
->output_section
,
4208 (file_ptr
) sec
->output_offset
, sec
->size
);
4213 #define elf32_bed elf32_tic6x_bed
4215 #define TARGET_LITTLE_SYM tic6x_elf32_le_vec
4216 #define TARGET_LITTLE_NAME "elf32-tic6x-le"
4217 #define TARGET_BIG_SYM tic6x_elf32_be_vec
4218 #define TARGET_BIG_NAME "elf32-tic6x-be"
4219 #define ELF_ARCH bfd_arch_tic6x
4220 #define ELF_TARGET_ID TIC6X_ELF_DATA
4221 #define ELF_MACHINE_CODE EM_TI_C6000
4222 #define ELF_MAXPAGESIZE 0x1000
4223 #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup
4224 #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup
4225 #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data
4226 #define bfd_elf32_mkobject elf32_tic6x_mkobject
4227 #define bfd_elf32_bfd_link_hash_table_create elf32_tic6x_link_hash_table_create
4228 #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook
4229 #define elf_backend_stack_align 8
4230 #define elf_backend_can_gc_sections 1
4231 #define elf_backend_default_use_rela_p 1
4232 #define elf_backend_may_use_rel_p 1
4233 #define elf_backend_may_use_rela_p 1
4234 #define elf_backend_obj_attrs_arg_type elf32_tic6x_obj_attrs_arg_type
4235 #define elf_backend_obj_attrs_handle_unknown elf32_tic6x_obj_attrs_handle_unknown
4236 #define elf_backend_obj_attrs_order elf32_tic6x_obj_attrs_order
4237 #define elf_backend_obj_attrs_section ".c6xabi.attributes"
4238 #define elf_backend_obj_attrs_section_type SHT_C6000_ATTRIBUTES
4239 #define elf_backend_obj_attrs_vendor "c6xabi"
4240 #define elf_backend_can_refcount 1
4241 #define elf_backend_want_got_plt 1
4242 #define elf_backend_want_dynbss 1
4243 #define elf_backend_want_dynrelro 1
4244 #define elf_backend_plt_readonly 1
4245 #define elf_backend_rela_normal 1
4246 #define elf_backend_got_header_size 8
4247 #define elf_backend_fake_sections elf32_tic6x_fake_sections
4248 #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections
4249 #define elf_backend_create_dynamic_sections \
4250 elf32_tic6x_create_dynamic_sections
4251 #define elf_backend_adjust_dynamic_symbol \
4252 elf32_tic6x_adjust_dynamic_symbol
4253 #define elf_backend_check_relocs elf32_tic6x_check_relocs
4254 #define elf_backend_add_symbol_hook elf32_tic6x_add_symbol_hook
4255 #define elf_backend_symbol_processing elf32_tic6x_symbol_processing
4256 #define elf_backend_link_output_symbol_hook \
4257 elf32_tic6x_link_output_symbol_hook
4258 #define elf_backend_section_from_bfd_section \
4259 elf32_tic6x_section_from_bfd_section
4260 #define elf_backend_relocate_section elf32_tic6x_relocate_section
4261 #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
4262 #define elf_backend_finish_dynamic_symbol \
4263 elf32_tic6x_finish_dynamic_symbol
4264 #define elf_backend_always_size_sections \
4265 elf32_tic6x_always_size_sections
4266 #define elf_backend_size_dynamic_sections \
4267 elf32_tic6x_size_dynamic_sections
4268 #define elf_backend_finish_dynamic_sections \
4269 elf32_tic6x_finish_dynamic_sections
4270 #define bfd_elf32_bfd_final_link \
4271 elf32_tic6x_final_link
4272 #define elf_backend_write_section elf32_tic6x_write_section
4273 #define elf_info_to_howto elf32_tic6x_info_to_howto
4274 #define elf_info_to_howto_rel elf32_tic6x_info_to_howto_rel
4276 #undef elf_backend_omit_section_dynsym
4277 #define elf_backend_omit_section_dynsym elf32_tic6x_link_omit_section_dynsym
4278 #define elf_backend_plt_sym_val elf32_tic6x_plt_sym_val
4280 #include "elf32-target.h"
4283 #define elf32_bed elf32_tic6x_linux_bed
4285 #undef TARGET_LITTLE_SYM
4286 #define TARGET_LITTLE_SYM tic6x_elf32_linux_le_vec
4287 #undef TARGET_LITTLE_NAME
4288 #define TARGET_LITTLE_NAME "elf32-tic6x-linux-le"
4289 #undef TARGET_BIG_SYM
4290 #define TARGET_BIG_SYM tic6x_elf32_linux_be_vec
4291 #undef TARGET_BIG_NAME
4292 #define TARGET_BIG_NAME "elf32-tic6x-linux-be"
4294 #define ELF_OSABI ELFOSABI_C6000_LINUX
4296 #include "elf32-target.h"
4299 #define elf32_bed elf32_tic6x_elf_bed
4301 #undef TARGET_LITTLE_SYM
4302 #define TARGET_LITTLE_SYM tic6x_elf32_c6000_le_vec
4303 #undef TARGET_LITTLE_NAME
4304 #define TARGET_LITTLE_NAME "elf32-tic6x-elf-le"
4305 #undef TARGET_BIG_SYM
4306 #define TARGET_BIG_SYM tic6x_elf32_c6000_be_vec
4307 #undef TARGET_BIG_NAME
4308 #define TARGET_BIG_NAME "elf32-tic6x-elf-be"
4310 #define ELF_OSABI ELFOSABI_C6000_ELFABI
4312 #include "elf32-target.h"