1 /* 32-bit ELF support for TI C6X
3 Free Software Foundation, Inc.
4 Contributed by Joseph Myers <joseph@codesourcery.com>
5 Bernd Schmidt <bernds@codesourcery.com>
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
27 #include "libiberty.h"
29 #include "elf/tic6x.h"
30 #include "elf32-tic6x.h"
32 struct elf32_tic6x_obj_tdata
34 struct elf_obj_tdata root;
36 /* Whether to use RELA relocations when generating relocations.
37 This is a per-object flag to allow the assembler to generate REL
38 relocations for use in linker testcases. */
39 bfd_boolean use_rela_p;
42 #define elf32_tic6x_tdata(abfd) \
43 ((struct elf32_tic6x_obj_tdata *) (abfd)->tdata.any)
45 static reloc_howto_type elf32_tic6x_howto_table[] =
47 HOWTO (R_C6000_NONE, /* type */
49 0, /* size (0 = byte, 1 = short, 2 = long) */
51 FALSE, /* pc_relative */
53 complain_overflow_dont,/* complain_on_overflow */
54 bfd_elf_generic_reloc, /* special_function */
55 "R_C6000_NONE", /* name */
56 FALSE, /* partial_inplace */
59 FALSE), /* pcrel_offset */
60 HOWTO (R_C6000_ABS32, /* type */
62 2, /* size (0 = byte, 1 = short, 2 = long) */
64 FALSE, /* pc_relative */
66 complain_overflow_dont,/* complain_on_overflow */
67 bfd_elf_generic_reloc, /* special_function */
68 "R_C6000_ABS32", /* name */
69 FALSE, /* partial_inplace */
71 0xffffffff, /* dst_mask */
72 FALSE), /* pcrel_offset */
73 HOWTO (R_C6000_ABS16, /* type */
75 1, /* size (0 = byte, 1 = short, 2 = long) */
77 FALSE, /* pc_relative */
79 complain_overflow_bitfield,/* complain_on_overflow */
80 bfd_elf_generic_reloc, /* special_function */
81 "R_C6000_ABS16", /* name */
82 FALSE, /* partial_inplace */
84 0x0000ffff, /* dst_mask */
85 FALSE), /* pcrel_offset */
86 HOWTO (R_C6000_ABS8, /* type */
88 0, /* size (0 = byte, 1 = short, 2 = long) */
90 FALSE, /* pc_relative */
92 complain_overflow_bitfield,/* complain_on_overflow */
93 bfd_elf_generic_reloc, /* special_function */
94 "R_C6000_ABS8", /* name */
95 FALSE, /* partial_inplace */
97 0x000000ff, /* dst_mask */
98 FALSE), /* pcrel_offset */
99 HOWTO (R_C6000_PCR_S21, /* type */
101 2, /* size (0 = byte, 1 = short, 2 = long) */
103 TRUE, /* pc_relative */
105 complain_overflow_signed,/* complain_on_overflow */
106 bfd_elf_generic_reloc, /* special_function */
107 "R_C6000_PCR_S21", /* name */
108 FALSE, /* partial_inplace */
110 0x0fffff80, /* dst_mask */
111 TRUE), /* pcrel_offset */
112 HOWTO (R_C6000_PCR_S12, /* type */
114 2, /* size (0 = byte, 1 = short, 2 = long) */
116 TRUE, /* pc_relative */
118 complain_overflow_signed,/* complain_on_overflow */
119 bfd_elf_generic_reloc, /* special_function */
120 "R_C6000_PCR_S12", /* name */
121 FALSE, /* partial_inplace */
123 0x0fff0000, /* dst_mask */
124 TRUE), /* pcrel_offset */
125 HOWTO (R_C6000_PCR_S10, /* type */
127 2, /* size (0 = byte, 1 = short, 2 = long) */
129 TRUE, /* pc_relative */
131 complain_overflow_signed,/* complain_on_overflow */
132 bfd_elf_generic_reloc, /* special_function */
133 "R_C6000_PCR_S10", /* name */
134 FALSE, /* partial_inplace */
136 0x007fe000, /* dst_mask */
137 TRUE), /* pcrel_offset */
138 HOWTO (R_C6000_PCR_S7, /* type */
140 2, /* size (0 = byte, 1 = short, 2 = long) */
142 TRUE, /* pc_relative */
144 complain_overflow_signed,/* complain_on_overflow */
145 bfd_elf_generic_reloc, /* special_function */
146 "R_C6000_PCR_S7", /* name */
147 FALSE, /* partial_inplace */
149 0x007f0000, /* dst_mask */
150 TRUE), /* pcrel_offset */
151 HOWTO (R_C6000_ABS_S16, /* type */
153 2, /* size (0 = byte, 1 = short, 2 = long) */
155 FALSE, /* pc_relative */
157 complain_overflow_signed,/* complain_on_overflow */
158 bfd_elf_generic_reloc, /* special_function */
159 "R_C6000_ABS_S16", /* name */
160 FALSE, /* partial_inplace */
162 0x007fff80, /* dst_mask */
163 FALSE), /* pcrel_offset */
164 HOWTO (R_C6000_ABS_L16, /* type */
166 2, /* size (0 = byte, 1 = short, 2 = long) */
168 FALSE, /* pc_relative */
170 complain_overflow_dont,/* complain_on_overflow */
171 bfd_elf_generic_reloc, /* special_function */
172 "R_C6000_ABS_L16", /* name */
173 FALSE, /* partial_inplace */
175 0x007fff80, /* dst_mask */
176 FALSE), /* pcrel_offset */
177 HOWTO (R_C6000_ABS_H16, /* type */
179 2, /* size (0 = byte, 1 = short, 2 = long) */
181 FALSE, /* pc_relative */
183 complain_overflow_dont,/* complain_on_overflow */
184 bfd_elf_generic_reloc, /* special_function */
185 "R_C6000_ABS_H16", /* name */
186 FALSE, /* partial_inplace */
188 0x007fff80, /* dst_mask */
189 FALSE), /* pcrel_offset */
190 HOWTO (R_C6000_SBR_U15_B, /* type */
192 2, /* size (0 = byte, 1 = short, 2 = long) */
194 FALSE, /* pc_relative */
196 complain_overflow_unsigned,/* complain_on_overflow */
197 bfd_elf_generic_reloc, /* special_function */
198 "R_C6000_SBR_U15_B", /* name */
199 FALSE, /* partial_inplace */
201 0x007fff00, /* dst_mask */
202 FALSE), /* pcrel_offset */
203 HOWTO (R_C6000_SBR_U15_H, /* type */
205 2, /* size (0 = byte, 1 = short, 2 = long) */
207 FALSE, /* pc_relative */
209 complain_overflow_unsigned,/* complain_on_overflow */
210 bfd_elf_generic_reloc, /* special_function */
211 "R_C6000_SBR_U15_H", /* name */
212 FALSE, /* partial_inplace */
214 0x007fff00, /* dst_mask */
215 FALSE), /* pcrel_offset */
216 HOWTO (R_C6000_SBR_U15_W, /* type */
218 2, /* size (0 = byte, 1 = short, 2 = long) */
220 FALSE, /* pc_relative */
222 complain_overflow_unsigned,/* complain_on_overflow */
223 bfd_elf_generic_reloc, /* special_function */
224 "R_C6000_SBR_U15_W", /* name */
225 FALSE, /* partial_inplace */
227 0x007fff00, /* dst_mask */
228 FALSE), /* pcrel_offset */
229 HOWTO (R_C6000_SBR_S16, /* type */
231 2, /* size (0 = byte, 1 = short, 2 = long) */
233 FALSE, /* pc_relative */
235 complain_overflow_signed,/* complain_on_overflow */
236 bfd_elf_generic_reloc, /* special_function */
237 "R_C6000_SBR_S16", /* name */
238 FALSE, /* partial_inplace */
240 0x007fff80, /* dst_mask */
241 FALSE), /* pcrel_offset */
242 HOWTO (R_C6000_SBR_L16_B, /* type */
244 2, /* size (0 = byte, 1 = short, 2 = long) */
246 FALSE, /* pc_relative */
248 complain_overflow_dont,/* complain_on_overflow */
249 bfd_elf_generic_reloc, /* special_function */
250 "R_C6000_SBR_L16_B", /* name */
251 FALSE, /* partial_inplace */
253 0x007fff80, /* dst_mask */
254 FALSE), /* pcrel_offset */
255 HOWTO (R_C6000_SBR_L16_H, /* type */
257 2, /* size (0 = byte, 1 = short, 2 = long) */
259 FALSE, /* pc_relative */
261 complain_overflow_dont,/* complain_on_overflow */
262 bfd_elf_generic_reloc, /* special_function */
263 "R_C6000_SBR_L16_H", /* name */
264 FALSE, /* partial_inplace */
266 0x007fff80, /* dst_mask */
267 FALSE), /* pcrel_offset */
268 HOWTO (R_C6000_SBR_L16_W, /* type */
270 2, /* size (0 = byte, 1 = short, 2 = long) */
272 FALSE, /* pc_relative */
274 complain_overflow_dont,/* complain_on_overflow */
275 bfd_elf_generic_reloc, /* special_function */
276 "R_C6000_SBR_L16_W", /* name */
277 FALSE, /* partial_inplace */
279 0x007fff80, /* dst_mask */
280 FALSE), /* pcrel_offset */
281 HOWTO (R_C6000_SBR_H16_B, /* type */
283 2, /* size (0 = byte, 1 = short, 2 = long) */
285 FALSE, /* pc_relative */
287 complain_overflow_dont,/* complain_on_overflow */
288 bfd_elf_generic_reloc, /* special_function */
289 "R_C6000_SBR_H16_B", /* name */
290 FALSE, /* partial_inplace */
292 0x007fff80, /* dst_mask */
293 FALSE), /* pcrel_offset */
294 HOWTO (R_C6000_SBR_H16_H, /* type */
296 2, /* size (0 = byte, 1 = short, 2 = long) */
298 FALSE, /* pc_relative */
300 complain_overflow_dont,/* complain_on_overflow */
301 bfd_elf_generic_reloc, /* special_function */
302 "R_C6000_SBR_H16_H", /* name */
303 FALSE, /* partial_inplace */
305 0x007fff80, /* dst_mask */
306 FALSE), /* pcrel_offset */
307 HOWTO (R_C6000_SBR_H16_W, /* type */
309 2, /* size (0 = byte, 1 = short, 2 = long) */
311 FALSE, /* pc_relative */
313 complain_overflow_dont,/* complain_on_overflow */
314 bfd_elf_generic_reloc, /* special_function */
315 "R_C6000_SBR_H16_W", /* name */
316 FALSE, /* partial_inplace */
318 0x007fff80, /* dst_mask */
319 FALSE), /* pcrel_offset */
320 HOWTO (R_C6000_SBR_GOT_U15_W, /* type */
322 2, /* size (0 = byte, 1 = short, 2 = long) */
324 FALSE, /* pc_relative */
326 complain_overflow_unsigned,/* complain_on_overflow */
327 bfd_elf_generic_reloc, /* special_function */
328 "R_C6000_SBR_GOT_U15_W",/* name */
329 FALSE, /* partial_inplace */
331 0x007fff00, /* dst_mask */
332 FALSE), /* pcrel_offset */
333 HOWTO (R_C6000_SBR_GOT_L16_W, /* type */
335 2, /* size (0 = byte, 1 = short, 2 = long) */
337 FALSE, /* pc_relative */
339 complain_overflow_dont,/* complain_on_overflow */
340 bfd_elf_generic_reloc, /* special_function */
341 "R_C6000_SBR_GOT_L16_W",/* name */
342 FALSE, /* partial_inplace */
344 0x007fff80, /* dst_mask */
345 FALSE), /* pcrel_offset */
346 HOWTO (R_C6000_SBR_GOT_H16_W, /* type */
348 2, /* size (0 = byte, 1 = short, 2 = long) */
350 FALSE, /* pc_relative */
352 complain_overflow_dont,/* complain_on_overflow */
353 bfd_elf_generic_reloc, /* special_function */
354 "R_C6000_SBR_GOT_H16_W",/* name */
355 FALSE, /* partial_inplace */
357 0x007fff80, /* dst_mask */
358 FALSE), /* pcrel_offset */
359 HOWTO (R_C6000_DSBT_INDEX, /* type */
361 2, /* size (0 = byte, 1 = short, 2 = long) */
363 FALSE, /* pc_relative */
365 complain_overflow_unsigned,/* complain_on_overflow */
366 bfd_elf_generic_reloc, /* special_function */
367 "R_C6000_DSBT_INDEX", /* name */
368 FALSE, /* partial_inplace */
370 0x007fff00, /* dst_mask */
371 FALSE), /* pcrel_offset */
372 HOWTO (R_C6000_PREL31, /* type */
374 2, /* size (0 = byte, 1 = short, 2 = long) */
376 FALSE, /* pc_relative */
378 complain_overflow_dont,/* complain_on_overflow */
379 bfd_elf_generic_reloc, /* special_function */
380 "R_C6000_PREL31", /* name */
381 FALSE, /* partial_inplace */
383 0x7fffffff, /* dst_mask */
384 FALSE), /* pcrel_offset */
385 HOWTO (R_C6000_COPY, /* type */
387 2, /* size (0 = byte, 1 = short, 2 = long) */
389 FALSE, /* pc_relative */
391 complain_overflow_dont,/* complain_on_overflow */
392 bfd_elf_generic_reloc, /* special_function */
393 "R_C6000_COPY", /* name */
394 FALSE, /* partial_inplace */
396 0xffffffff, /* dst_mask */
397 FALSE), /* pcrel_offset */
624 HOWTO (R_C6000_ALIGN, /* type */
626 0, /* size (0 = byte, 1 = short, 2 = long) */
628 FALSE, /* pc_relative */
630 complain_overflow_dont,/* complain_on_overflow */
631 bfd_elf_generic_reloc, /* special_function */
632 "R_C6000_ALIGN", /* name */
633 FALSE, /* partial_inplace */
636 FALSE), /* pcrel_offset */
637 HOWTO (R_C6000_FPHEAD, /* type */
639 0, /* size (0 = byte, 1 = short, 2 = long) */
641 FALSE, /* pc_relative */
643 complain_overflow_dont,/* complain_on_overflow */
644 bfd_elf_generic_reloc, /* special_function */
645 "R_C6000_FPHEAD", /* name */
646 FALSE, /* partial_inplace */
649 FALSE), /* pcrel_offset */
650 HOWTO (R_C6000_NOCMP, /* type */
652 0, /* size (0 = byte, 1 = short, 2 = long) */
654 FALSE, /* pc_relative */
656 complain_overflow_dont,/* complain_on_overflow */
657 bfd_elf_generic_reloc, /* special_function */
658 "R_C6000_NOCMP", /* name */
659 FALSE, /* partial_inplace */
662 FALSE) /* pcrel_offset */
665 static reloc_howto_type elf32_tic6x_howto_table_rel[] =
667 HOWTO (R_C6000_NONE, /* type */
669 0, /* size (0 = byte, 1 = short, 2 = long) */
671 FALSE, /* pc_relative */
673 complain_overflow_dont,/* complain_on_overflow */
674 bfd_elf_generic_reloc, /* special_function */
675 "R_C6000_NONE", /* name */
676 TRUE, /* partial_inplace */
679 FALSE), /* pcrel_offset */
680 HOWTO (R_C6000_ABS32, /* type */
682 2, /* size (0 = byte, 1 = short, 2 = long) */
684 FALSE, /* pc_relative */
686 complain_overflow_dont,/* complain_on_overflow */
687 bfd_elf_generic_reloc, /* special_function */
688 "R_C6000_ABS32", /* name */
689 TRUE, /* partial_inplace */
690 0xffffffff, /* src_mask */
691 0xffffffff, /* dst_mask */
692 FALSE), /* pcrel_offset */
693 HOWTO (R_C6000_ABS16, /* type */
695 1, /* size (0 = byte, 1 = short, 2 = long) */
697 FALSE, /* pc_relative */
699 complain_overflow_bitfield,/* complain_on_overflow */
700 bfd_elf_generic_reloc, /* special_function */
701 "R_C6000_ABS16", /* name */
702 TRUE, /* partial_inplace */
703 0x0000ffff, /* src_mask */
704 0x0000ffff, /* dst_mask */
705 FALSE), /* pcrel_offset */
706 HOWTO (R_C6000_ABS8, /* type */
708 0, /* size (0 = byte, 1 = short, 2 = long) */
710 FALSE, /* pc_relative */
712 complain_overflow_bitfield,/* complain_on_overflow */
713 bfd_elf_generic_reloc, /* special_function */
714 "R_C6000_ABS8", /* name */
715 TRUE, /* partial_inplace */
716 0x000000ff, /* src_mask */
717 0x000000ff, /* dst_mask */
718 FALSE), /* pcrel_offset */
719 HOWTO (R_C6000_PCR_S21, /* type */
721 2, /* size (0 = byte, 1 = short, 2 = long) */
723 TRUE, /* pc_relative */
725 complain_overflow_signed,/* complain_on_overflow */
726 bfd_elf_generic_reloc, /* special_function */
727 "R_C6000_PCR_S21", /* name */
728 TRUE, /* partial_inplace */
729 0x0fffff80, /* src_mask */
730 0x0fffff80, /* dst_mask */
731 TRUE), /* pcrel_offset */
732 HOWTO (R_C6000_PCR_S12, /* type */
734 2, /* size (0 = byte, 1 = short, 2 = long) */
736 TRUE, /* pc_relative */
738 complain_overflow_signed,/* complain_on_overflow */
739 bfd_elf_generic_reloc, /* special_function */
740 "R_C6000_PCR_S12", /* name */
741 TRUE, /* partial_inplace */
742 0x0fff0000, /* src_mask */
743 0x0fff0000, /* dst_mask */
744 TRUE), /* pcrel_offset */
745 HOWTO (R_C6000_PCR_S10, /* type */
747 2, /* size (0 = byte, 1 = short, 2 = long) */
749 TRUE, /* pc_relative */
751 complain_overflow_signed,/* complain_on_overflow */
752 bfd_elf_generic_reloc, /* special_function */
753 "R_C6000_PCR_S10", /* name */
754 TRUE, /* partial_inplace */
755 0x007fe000, /* src_mask */
756 0x007fe000, /* dst_mask */
757 TRUE), /* pcrel_offset */
758 HOWTO (R_C6000_PCR_S7, /* type */
760 2, /* size (0 = byte, 1 = short, 2 = long) */
762 TRUE, /* pc_relative */
764 complain_overflow_signed,/* complain_on_overflow */
765 bfd_elf_generic_reloc, /* special_function */
766 "R_C6000_PCR_S7", /* name */
767 TRUE, /* partial_inplace */
768 0x007f0000, /* src_mask */
769 0x007f0000, /* dst_mask */
770 TRUE), /* pcrel_offset */
771 HOWTO (R_C6000_ABS_S16, /* type */
773 2, /* size (0 = byte, 1 = short, 2 = long) */
775 FALSE, /* pc_relative */
777 complain_overflow_signed,/* complain_on_overflow */
778 bfd_elf_generic_reloc, /* special_function */
779 "R_C6000_ABS_S16", /* name */
780 TRUE, /* partial_inplace */
781 0x007fff80, /* src_mask */
782 0x007fff80, /* dst_mask */
783 FALSE), /* pcrel_offset */
784 HOWTO (R_C6000_ABS_L16, /* type */
786 2, /* size (0 = byte, 1 = short, 2 = long) */
788 FALSE, /* pc_relative */
790 complain_overflow_dont,/* complain_on_overflow */
791 bfd_elf_generic_reloc, /* special_function */
792 "R_C6000_ABS_L16", /* name */
793 TRUE, /* partial_inplace */
794 0x007fff80, /* src_mask */
795 0x007fff80, /* dst_mask */
796 FALSE), /* pcrel_offset */
797 EMPTY_HOWTO (R_C6000_ABS_H16),
798 HOWTO (R_C6000_SBR_U15_B, /* type */
800 2, /* size (0 = byte, 1 = short, 2 = long) */
802 FALSE, /* pc_relative */
804 complain_overflow_unsigned,/* complain_on_overflow */
805 bfd_elf_generic_reloc, /* special_function */
806 "R_C6000_SBR_U15_B", /* name */
807 TRUE, /* partial_inplace */
808 0x007fff00, /* src_mask */
809 0x007fff00, /* dst_mask */
810 FALSE), /* pcrel_offset */
811 HOWTO (R_C6000_SBR_U15_H, /* type */
813 2, /* size (0 = byte, 1 = short, 2 = long) */
815 FALSE, /* pc_relative */
817 complain_overflow_unsigned,/* complain_on_overflow */
818 bfd_elf_generic_reloc, /* special_function */
819 "R_C6000_SBR_U15_H", /* name */
820 TRUE, /* partial_inplace */
821 0x007fff00, /* src_mask */
822 0x007fff00, /* dst_mask */
823 FALSE), /* pcrel_offset */
824 HOWTO (R_C6000_SBR_U15_W, /* type */
826 2, /* size (0 = byte, 1 = short, 2 = long) */
828 FALSE, /* pc_relative */
830 complain_overflow_unsigned,/* complain_on_overflow */
831 bfd_elf_generic_reloc, /* special_function */
832 "R_C6000_SBR_U15_W", /* name */
833 TRUE, /* partial_inplace */
834 0x007fff00, /* src_mask */
835 0x007fff00, /* dst_mask */
836 FALSE), /* pcrel_offset */
837 HOWTO (R_C6000_SBR_S16, /* type */
839 2, /* size (0 = byte, 1 = short, 2 = long) */
841 FALSE, /* pc_relative */
843 complain_overflow_signed,/* complain_on_overflow */
844 bfd_elf_generic_reloc, /* special_function */
845 "R_C6000_SBR_S16", /* name */
846 TRUE, /* partial_inplace */
847 0x007fff80, /* src_mask */
848 0x007fff80, /* dst_mask */
849 FALSE), /* pcrel_offset */
850 HOWTO (R_C6000_SBR_L16_B, /* type */
852 2, /* size (0 = byte, 1 = short, 2 = long) */
854 FALSE, /* pc_relative */
856 complain_overflow_dont,/* complain_on_overflow */
857 bfd_elf_generic_reloc, /* special_function */
858 "R_C6000_SBR_L16_B", /* name */
859 TRUE, /* partial_inplace */
860 0x007fff80, /* src_mask */
861 0x007fff80, /* dst_mask */
862 FALSE), /* pcrel_offset */
863 HOWTO (R_C6000_SBR_L16_H, /* type */
865 2, /* size (0 = byte, 1 = short, 2 = long) */
867 FALSE, /* pc_relative */
869 complain_overflow_dont,/* complain_on_overflow */
870 bfd_elf_generic_reloc, /* special_function */
871 "R_C6000_SBR_L16_H", /* name */
872 TRUE, /* partial_inplace */
873 0x007fff80, /* src_mask */
874 0x007fff80, /* dst_mask */
875 FALSE), /* pcrel_offset */
876 HOWTO (R_C6000_SBR_L16_W, /* type */
878 2, /* size (0 = byte, 1 = short, 2 = long) */
880 FALSE, /* pc_relative */
882 complain_overflow_dont,/* complain_on_overflow */
883 bfd_elf_generic_reloc, /* special_function */
884 "R_C6000_SBR_L16_W", /* name */
885 TRUE, /* partial_inplace */
886 0x007fff80, /* src_mask */
887 0x007fff80, /* dst_mask */
888 FALSE), /* pcrel_offset */
889 EMPTY_HOWTO (R_C6000_SBR_H16_B),
890 EMPTY_HOWTO (R_C6000_SBR_H16_H),
891 EMPTY_HOWTO (R_C6000_SBR_H16_W),
892 HOWTO (R_C6000_SBR_GOT_U15_W, /* type */
894 2, /* size (0 = byte, 1 = short, 2 = long) */
896 FALSE, /* pc_relative */
898 complain_overflow_unsigned,/* complain_on_overflow */
899 bfd_elf_generic_reloc, /* special_function */
900 "R_C6000_SBR_GOT_U15_W",/* name */
901 TRUE, /* partial_inplace */
902 0x007fff00, /* src_mask */
903 0x007fff00, /* dst_mask */
904 FALSE), /* pcrel_offset */
905 HOWTO (R_C6000_SBR_GOT_L16_W, /* type */
907 2, /* size (0 = byte, 1 = short, 2 = long) */
909 FALSE, /* pc_relative */
911 complain_overflow_dont,/* complain_on_overflow */
912 bfd_elf_generic_reloc, /* special_function */
913 "R_C6000_SBR_GOT_L16_W",/* name */
914 TRUE, /* partial_inplace */
915 0x007fff80, /* src_mask */
916 0x007fff80, /* dst_mask */
917 FALSE), /* pcrel_offset */
918 EMPTY_HOWTO (R_C6000_SBR_GOT_H16_W),
919 HOWTO (R_C6000_DSBT_INDEX, /* type */
921 2, /* size (0 = byte, 1 = short, 2 = long) */
923 FALSE, /* pc_relative */
925 complain_overflow_unsigned,/* complain_on_overflow */
926 bfd_elf_generic_reloc, /* special_function */
927 "R_C6000_DSBT_INDEX", /* name */
928 TRUE, /* partial_inplace */
930 0x007fff00, /* dst_mask */
931 FALSE), /* pcrel_offset */
932 HOWTO (R_C6000_PREL31, /* type */
934 2, /* size (0 = byte, 1 = short, 2 = long) */
936 FALSE, /* pc_relative */
938 complain_overflow_dont,/* complain_on_overflow */
939 bfd_elf_generic_reloc, /* special_function */
940 "R_C6000_PREL31", /* name */
941 TRUE, /* partial_inplace */
943 0x7fffffff, /* dst_mask */
944 FALSE), /* pcrel_offset */
945 HOWTO (R_C6000_COPY, /* type */
947 2, /* size (0 = byte, 1 = short, 2 = long) */
949 FALSE, /* pc_relative */
951 complain_overflow_dont,/* complain_on_overflow */
952 bfd_elf_generic_reloc, /* special_function */
953 "R_C6000_COPY", /* name */
954 TRUE, /* partial_inplace */
956 0xffffffff, /* dst_mask */
957 FALSE), /* pcrel_offset */
1184 HOWTO (R_C6000_ALIGN, /* type */
1186 0, /* size (0 = byte, 1 = short, 2 = long) */
1188 FALSE, /* pc_relative */
1190 complain_overflow_dont,/* complain_on_overflow */
1191 bfd_elf_generic_reloc, /* special_function */
1192 "R_C6000_ALIGN", /* name */
1193 TRUE, /* partial_inplace */
1196 FALSE), /* pcrel_offset */
1197 HOWTO (R_C6000_FPHEAD, /* type */
1199 0, /* size (0 = byte, 1 = short, 2 = long) */
1201 FALSE, /* pc_relative */
1203 complain_overflow_dont,/* complain_on_overflow */
1204 bfd_elf_generic_reloc, /* special_function */
1205 "R_C6000_FPHEAD", /* name */
1206 TRUE, /* partial_inplace */
1209 FALSE), /* pcrel_offset */
1210 HOWTO (R_C6000_NOCMP, /* type */
1212 0, /* size (0 = byte, 1 = short, 2 = long) */
1214 FALSE, /* pc_relative */
1216 complain_overflow_dont,/* complain_on_overflow */
1217 bfd_elf_generic_reloc, /* special_function */
1218 "R_C6000_NOCMP", /* name */
1219 TRUE, /* partial_inplace */
1222 FALSE) /* pcrel_offset */
1225 /* Map BFD relocations to ELF relocations. */
1229 bfd_reloc_code_real_type bfd_reloc_val;
1230 enum elf_tic6x_reloc_type elf_reloc_val;
1233 static const tic6x_reloc_map elf32_tic6x_reloc_map[] =
1235 { BFD_RELOC_NONE, R_C6000_NONE },
1236 { BFD_RELOC_32, R_C6000_ABS32 },
1237 { BFD_RELOC_16, R_C6000_ABS16 },
1238 { BFD_RELOC_8, R_C6000_ABS8 },
1239 { BFD_RELOC_C6000_PCR_S21, R_C6000_PCR_S21 },
1240 { BFD_RELOC_C6000_PCR_S12, R_C6000_PCR_S12 },
1241 { BFD_RELOC_C6000_PCR_S10, R_C6000_PCR_S10 },
1242 { BFD_RELOC_C6000_PCR_S7, R_C6000_PCR_S7 },
1243 { BFD_RELOC_C6000_ABS_S16, R_C6000_ABS_S16 },
1244 { BFD_RELOC_C6000_ABS_L16, R_C6000_ABS_L16 },
1245 { BFD_RELOC_C6000_ABS_H16, R_C6000_ABS_H16 },
1246 { BFD_RELOC_C6000_SBR_U15_B, R_C6000_SBR_U15_B },
1247 { BFD_RELOC_C6000_SBR_U15_H, R_C6000_SBR_U15_H },
1248 { BFD_RELOC_C6000_SBR_U15_W, R_C6000_SBR_U15_W },
1249 { BFD_RELOC_C6000_SBR_S16, R_C6000_SBR_S16 },
1250 { BFD_RELOC_C6000_SBR_L16_B, R_C6000_SBR_L16_B },
1251 { BFD_RELOC_C6000_SBR_L16_H, R_C6000_SBR_L16_H },
1252 { BFD_RELOC_C6000_SBR_L16_W, R_C6000_SBR_L16_W },
1253 { BFD_RELOC_C6000_SBR_H16_B, R_C6000_SBR_H16_B },
1254 { BFD_RELOC_C6000_SBR_H16_H, R_C6000_SBR_H16_H },
1255 { BFD_RELOC_C6000_SBR_H16_W, R_C6000_SBR_H16_W },
1256 { BFD_RELOC_C6000_SBR_GOT_U15_W, R_C6000_SBR_GOT_U15_W },
1257 { BFD_RELOC_C6000_SBR_GOT_L16_W, R_C6000_SBR_GOT_L16_W },
1258 { BFD_RELOC_C6000_SBR_GOT_H16_W, R_C6000_SBR_GOT_H16_W },
1259 { BFD_RELOC_C6000_DSBT_INDEX, R_C6000_DSBT_INDEX },
1260 { BFD_RELOC_C6000_PREL31, R_C6000_PREL31 },
1261 { BFD_RELOC_C6000_COPY, R_C6000_COPY },
1262 { BFD_RELOC_C6000_ALIGN, R_C6000_ALIGN },
1263 { BFD_RELOC_C6000_FPHEAD, R_C6000_FPHEAD },
1264 { BFD_RELOC_C6000_NOCMP, R_C6000_NOCMP }
1267 static reloc_howto_type *
1268 elf32_tic6x_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
1272 for (i = 0; i < ARRAY_SIZE (elf32_tic6x_reloc_map); i++)
1273 if (elf32_tic6x_reloc_map[i].bfd_reloc_val == code)
1275 enum elf_tic6x_reloc_type elf_reloc_val;
1276 reloc_howto_type *howto;
1278 elf_reloc_val = elf32_tic6x_reloc_map[i].elf_reloc_val;
1279 if (elf32_tic6x_tdata (abfd)->use_rela_p)
1280 howto = &elf32_tic6x_howto_table[elf_reloc_val];
1282 howto = &elf32_tic6x_howto_table_rel[elf_reloc_val];
1284 /* Some relocations are RELA-only; do not return them for
1286 if (howto->name == NULL)
1295 static reloc_howto_type *
1296 elf32_tic6x_reloc_name_lookup (bfd *abfd, const char *r_name)
1298 if (elf32_tic6x_tdata (abfd)->use_rela_p)
1302 for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table); i++)
1303 if (elf32_tic6x_howto_table[i].name != NULL
1304 && strcasecmp (elf32_tic6x_howto_table[i].name, r_name) == 0)
1305 return &elf32_tic6x_howto_table[i];
1311 for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table_rel); i++)
1312 if (elf32_tic6x_howto_table_rel[i].name != NULL
1313 && strcasecmp (elf32_tic6x_howto_table_rel[i].name, r_name) == 0)
1314 return &elf32_tic6x_howto_table_rel[i];
1321 elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
1322 Elf_Internal_Rela *elf_reloc)
1324 unsigned int r_type;
1326 r_type = ELF32_R_TYPE (elf_reloc->r_info);
1327 if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table))
1328 bfd_reloc->howto = NULL;
1330 bfd_reloc->howto = &elf32_tic6x_howto_table[r_type];
1334 elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
1335 Elf_Internal_Rela *elf_reloc)
1337 unsigned int r_type;
1339 r_type = ELF32_R_TYPE (elf_reloc->r_info);
1340 if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table_rel))
1341 bfd_reloc->howto = NULL;
1343 bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type];
1347 elf32_tic6x_set_use_rela_p (bfd *abfd, bfd_boolean use_rela_p)
1349 elf32_tic6x_tdata (abfd)->use_rela_p = use_rela_p;
1353 elf32_tic6x_mkobject (bfd *abfd)
1357 ret = bfd_elf_allocate_object (abfd, sizeof (struct elf32_tic6x_obj_tdata),
1360 elf32_tic6x_set_use_rela_p (abfd, TRUE);
1365 elf32_tic6x_new_section_hook (bfd *abfd, asection *sec)
1369 ret = _bfd_elf_new_section_hook (abfd, sec);
1370 sec->use_rela_p = elf32_tic6x_tdata (abfd)->use_rela_p;
1375 /* Return true if relocation REL against section SEC is a REL rather
1376 than RELA relocation. RELOCS is the first relocation in the
1377 section and ABFD is the bfd that contains SEC. */
1380 elf32_tic6x_rel_relocation_p (bfd *abfd, asection *sec,
1381 const Elf_Internal_Rela *relocs,
1382 const Elf_Internal_Rela *rel)
1384 Elf_Internal_Shdr *rel_hdr;
1385 const struct elf_backend_data *bed;
1387 /* To determine which flavor of relocation this is, we depend on the
1388 fact that the INPUT_SECTION's REL_HDR is read before RELA_HDR. */
1389 rel_hdr = elf_section_data (sec)->rel.hdr;
1390 if (rel_hdr == NULL)
1392 bed = get_elf_backend_data (abfd);
1393 return ((size_t) (rel - relocs)
1394 < NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel);
1398 elf32_tic6x_relocate_section (bfd *output_bfd,
1399 struct bfd_link_info *info,
1401 asection *input_section,
1403 Elf_Internal_Rela *relocs,
1404 Elf_Internal_Sym *local_syms,
1405 asection **local_sections)
1407 Elf_Internal_Shdr *symtab_hdr;
1408 struct elf_link_hash_entry **sym_hashes;
1409 Elf_Internal_Rela *rel;
1410 Elf_Internal_Rela *relend;
1411 bfd_boolean ok = TRUE;
1413 symtab_hdr = & elf_symtab_hdr (input_bfd);
1414 sym_hashes = elf_sym_hashes (input_bfd);
1416 relend = relocs + input_section->reloc_count;
1418 for (rel = relocs; rel < relend; rel ++)
1421 unsigned long r_symndx;
1423 reloc_howto_type *howto;
1424 Elf_Internal_Sym *sym;
1426 struct elf_link_hash_entry *h;
1428 bfd_boolean unresolved_reloc;
1429 bfd_reloc_status_type r;
1430 struct bfd_link_hash_entry *sbh;
1433 r_type = ELF32_R_TYPE (rel->r_info);
1434 r_symndx = ELF32_R_SYM (rel->r_info);
1436 is_rel = elf32_tic6x_rel_relocation_p (input_bfd, input_section,
1440 elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel);
1442 elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel);
1443 howto = bfd_reloc.howto;
1446 bfd_set_error (bfd_error_bad_value);
1453 unresolved_reloc = FALSE;
1455 if (r_symndx < symtab_hdr->sh_info)
1457 sym = local_syms + r_symndx;
1458 sec = local_sections[r_symndx];
1459 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1465 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1466 r_symndx, symtab_hdr, sym_hashes,
1468 unresolved_reloc, warned);
1471 if (sec != NULL && elf_discarded_section (sec))
1472 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
1473 rel, relend, howto, contents);
1475 if (info->relocatable)
1479 && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1482 relocation = sec->output_offset + sym->st_value;
1483 r = _bfd_relocate_contents (howto, input_bfd, relocation,
1484 contents + rel->r_offset);
1494 case R_C6000_FPHEAD:
1496 /* No action needed. */
1499 case R_C6000_PCR_S21:
1500 case R_C6000_PCR_S12:
1501 case R_C6000_PCR_S10:
1502 case R_C6000_PCR_S7:
1503 /* Generic PC-relative handling produces a value relative to
1504 the exact location of the relocation. Adjust it to be
1505 relative to the start of the fetch packet instead. */
1506 relocation += (input_section->output_section->vma
1507 + input_section->output_offset
1508 + rel->r_offset) & 0x1f;
1513 case R_C6000_ABS_S16:
1514 case R_C6000_ABS_L16:
1515 case R_C6000_ABS_H16:
1516 /* Generic logic OK. */
1519 case R_C6000_SBR_U15_B:
1520 case R_C6000_SBR_U15_H:
1521 case R_C6000_SBR_U15_W:
1522 case R_C6000_SBR_S16:
1523 case R_C6000_SBR_L16_B:
1524 case R_C6000_SBR_L16_H:
1525 case R_C6000_SBR_L16_W:
1526 case R_C6000_SBR_H16_B:
1527 case R_C6000_SBR_H16_H:
1528 case R_C6000_SBR_H16_W:
1529 sbh = bfd_link_hash_lookup (info->hash, "__c6xabi_DSBT_BASE",
1530 FALSE, FALSE, TRUE);
1532 && (sbh->type == bfd_link_hash_defined
1533 || sbh->type == bfd_link_hash_defweak))
1534 relocation -= (sbh->u.def.value
1535 + sbh->u.def.section->output_section->vma
1536 + sbh->u.def.section->output_offset);
1539 (*_bfd_error_handler) (_("%B: SB-relative relocation but "
1540 "__c6xabi_DSBT_BASE not defined"),
1547 case R_C6000_SBR_GOT_U15_W:
1548 case R_C6000_SBR_GOT_L16_W:
1549 case R_C6000_SBR_GOT_H16_W:
1550 case R_C6000_DSBT_INDEX:
1551 case R_C6000_PREL31:
1552 /* Shared libraries and exception handling support not
1554 (*_bfd_error_handler) (_("%B: relocation type %d not implemented"),
1560 /* Invalid in relocatable object. */
1562 /* Unknown relocation. */
1563 (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
1569 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1570 contents, rel->r_offset,
1571 relocation, rel->r_addend);
1574 if (r == bfd_reloc_ok
1575 && howto->complain_on_overflow == complain_overflow_bitfield)
1577 /* Generic overflow handling accepts cases the ABI says
1578 should be rejected for R_C6000_ABS16 and
1580 bfd_vma value = (relocation + rel->r_addend) & 0xffffffff;
1581 bfd_vma sbit = 1 << (howto->bitsize - 1);
1582 bfd_vma sbits = (-(bfd_vma) sbit) & 0xffffffff;
1583 bfd_vma value_sbits = value & sbits;
1585 if (value_sbits != 0
1586 && value_sbits != sbit
1587 && value_sbits != sbits)
1588 r = bfd_reloc_overflow;
1591 if (r != bfd_reloc_ok)
1594 const char *error_message;
1597 name = h->root.root.string;
1600 name = bfd_elf_string_from_elf_section (input_bfd,
1601 symtab_hdr->sh_link,
1606 name = bfd_section_name (input_bfd, sec);
1611 case bfd_reloc_overflow:
1612 /* If the overflowing reloc was to an undefined symbol,
1613 we have already printed one error message and there
1614 is no point complaining again. */
1616 h->root.type != bfd_link_hash_undefined)
1617 && (!((*info->callbacks->reloc_overflow)
1618 (info, (h ? &h->root : NULL), name, howto->name,
1619 (bfd_vma) 0, input_bfd, input_section,
1624 case bfd_reloc_undefined:
1625 if (!((*info->callbacks->undefined_symbol)
1626 (info, name, input_bfd, input_section,
1627 rel->r_offset, TRUE)))
1631 case bfd_reloc_outofrange:
1632 error_message = _("out of range");
1635 case bfd_reloc_notsupported:
1636 error_message = _("unsupported relocation");
1639 case bfd_reloc_dangerous:
1640 error_message = _("dangerous relocation");
1644 error_message = _("unknown error");
1648 BFD_ASSERT (error_message != NULL);
1649 if (!((*info->callbacks->reloc_dangerous)
1650 (info, error_message, input_bfd, input_section,
1662 elf32_tic6x_obj_attrs_arg_type (int tag)
1664 if (tag == Tag_compatibility)
1665 return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL;
1667 /* Correct for known attributes, arbitrary for others. */
1668 return ATTR_TYPE_FLAG_INT_VAL;
1671 /* Merge the Tag_ISA attribute values ARCH1 and ARCH2
1672 and return the merged value. At present, all merges succeed, so no
1673 return value for errors is defined. */
1676 elf32_tic6x_merge_arch_attributes (int arch1, int arch2)
1678 int min_arch, max_arch;
1680 min_arch = (arch1 < arch2 ? arch1 : arch2);
1681 max_arch = (arch1 > arch2 ? arch1 : arch2);
1683 /* In most cases, the numerically greatest value is the correct
1684 merged value, but merging C64 and C67 results in C674X. */
1685 if ((min_arch == C6XABI_Tag_ISA_C67X
1686 || min_arch == C6XABI_Tag_ISA_C67XP)
1687 && (max_arch == C6XABI_Tag_ISA_C64X
1688 || max_arch == C6XABI_Tag_ISA_C64XP))
1689 return C6XABI_Tag_ISA_C674X;
1694 /* Merge attributes from IBFD and OBFD, returning TRUE if the merge
1695 succeeded, FALSE otherwise. */
1698 elf32_tic6x_merge_attributes (bfd *ibfd, bfd *obfd)
1700 obj_attribute *in_attr;
1701 obj_attribute *out_attr;
1703 if (!elf_known_obj_attributes_proc (obfd)[0].i)
1705 /* This is the first object. Copy the attributes. */
1706 _bfd_elf_copy_obj_attributes (ibfd, obfd);
1708 out_attr = elf_known_obj_attributes_proc (obfd);
1710 /* Use the Tag_null value to indicate the attributes have been
1717 in_attr = elf_known_obj_attributes_proc (ibfd);
1718 out_attr = elf_known_obj_attributes_proc (obfd);
1720 /* No specification yet for handling of unknown attributes, so just
1721 ignore them and handle known ones. */
1723 = elf32_tic6x_merge_arch_attributes (in_attr[Tag_ISA].i,
1724 out_attr[Tag_ISA].i);
1726 if (out_attr[Tag_ABI_DSBT].i != in_attr[Tag_ABI_DSBT].i)
1729 (_("warning: %B and %B differ in whether code is compiled for DSBT"),
1732 /* Merge Tag_compatibility attributes and any common GNU ones. */
1733 _bfd_elf_merge_object_attributes (ibfd, obfd);
1739 elf32_tic6x_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
1741 if (!_bfd_generic_verify_endian_match (ibfd, obfd))
1744 if (!elf32_tic6x_merge_attributes (ibfd, obfd))
1751 #define TARGET_LITTLE_SYM bfd_elf32_tic6x_le_vec
1752 #define TARGET_LITTLE_NAME "elf32-tic6x-le"
1753 #define TARGET_BIG_SYM bfd_elf32_tic6x_be_vec
1754 #define TARGET_BIG_NAME "elf32-tic6x-be"
1755 #define ELF_ARCH bfd_arch_tic6x
1756 #define ELF_TARGET_ID TIC6X_ELF_DATA
1757 #define ELF_MACHINE_CODE EM_TI_C6000
1758 #define ELF_MAXPAGESIZE 1
1759 #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup
1760 #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup
1761 #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data
1762 #define bfd_elf32_mkobject elf32_tic6x_mkobject
1763 #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook
1764 #define elf_backend_can_gc_sections 1
1765 #define elf_backend_default_use_rela_p 1
1766 #define elf_backend_may_use_rel_p 1
1767 #define elf_backend_may_use_rela_p 1
1768 #define elf_backend_obj_attrs_arg_type elf32_tic6x_obj_attrs_arg_type
1769 #define elf_backend_obj_attrs_section ".c6xabi.attributes"
1770 #define elf_backend_obj_attrs_section_type SHT_C6000_ATTRIBUTES
1771 #define elf_backend_obj_attrs_vendor "c6xabi"
1772 #define elf_backend_rela_normal 1
1773 #define elf_backend_relocate_section elf32_tic6x_relocate_section
1774 #define elf_info_to_howto elf32_tic6x_info_to_howto
1775 #define elf_info_to_howto_rel elf32_tic6x_info_to_howto_rel
1777 #include "elf32-target.h"