Commit | Line | Data |
---|---|---|
cd6213ff | 1 | /* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP). |
69f3f9f7 | 2 | Copyright 1996, 1997 Free Software Foundation, Inc. |
cd6213ff FF |
3 | |
4 | Written by Fred Fish (fnf@cygnus.com) | |
5 | ||
6 | There is nothing new under the sun. This file draws a lot on other | |
7 | coff files. | |
8 | ||
9 | This file is part of BFD, the Binary File Descriptor library. | |
10 | ||
11 | This program is free software; you can redistribute it and/or modify | |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 2 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | This program is distributed in the hope that it will be useful, | |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU General Public License | |
22 | along with this program; if not, write to the Free Software | |
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
5a608f5b FF |
24 | |
25 | #include "bfd.h" | |
26 | #include "sysdep.h" | |
27 | #include "libbfd.h" | |
5a608f5b FF |
28 | #include "coff/tic80.h" |
29 | #include "coff/internal.h" | |
30 | #include "libcoff.h" | |
31 | ||
69f3f9f7 MA |
32 | #define NAMES_HAVE_UNDERSCORE |
33 | ||
4507d858 | 34 | #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) |
5a608f5b FF |
35 | |
36 | #define coff_relocate_section _bfd_coff_generic_relocate_section | |
37 | ||
4507d858 FF |
38 | static void rtype2howto PARAMS ((arelent *cache_ptr, struct internal_reloc *dst)); |
39 | ||
40 | static reloc_howto_type tic80_howto_table[] = | |
41 | { | |
42 | ||
43 | HOWTO (R_RELLONG, /* type */ | |
44 | 0, /* rightshift */ | |
45 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
46 | 32, /* bitsize */ | |
47 | false, /* pc_relative */ | |
48 | 0, /* bitpos */ | |
49 | complain_overflow_bitfield, /* complain_on_overflow */ | |
50 | NULL, /* special_function */ | |
51 | "32", /* name */ | |
52 | true, /* partial_inplace */ | |
53 | 0xffffffff, /* src_mask */ | |
54 | 0xffffffff, /* dst_mask */ | |
55 | false), /* pcrel_offset */ | |
56 | ||
57 | HOWTO (R_MPPCR, /* type */ | |
58 | 0, /* rightshift */ | |
59 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
60 | 32, /* bitsize */ | |
61 | true, /* pc_relative */ | |
62 | 0, /* bitpos */ | |
63 | complain_overflow_dont, /* complain_on_overflow */ | |
64 | NULL, /* special_function */ | |
65 | "MPPCR", /* name */ | |
66 | true, /* partial_inplace */ | |
67 | 0xffffffff, /* src_mask */ | |
68 | 0xffffffff, /* dst_mask */ | |
69 | true), /* pcrel_offset */ | |
69f3f9f7 MA |
70 | |
71 | HOWTO (R_ABS, /* type */ | |
72 | 0, /* rightshift */ | |
73 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
74 | 32, /* bitsize */ | |
75 | false, /* pc_relative */ | |
76 | 0, /* bitpos */ | |
77 | complain_overflow_bitfield, /* complain_on_overflow */ | |
78 | NULL, /* special_function */ | |
79 | "ABS", /* name */ | |
80 | true, /* partial_inplace */ | |
81 | 0xffffffff, /* src_mask */ | |
82 | 0xffffffff, /* dst_mask */ | |
83 | false), /* pcrel_offset */ | |
4507d858 FF |
84 | }; |
85 | ||
86 | /* Code to turn an external r_type into a pointer to an entry in the howto_table. | |
69f3f9f7 MA |
87 | If passed an r_type we don't recognize the abort rather than silently failing |
88 | to generate an output file. */ | |
4507d858 FF |
89 | |
90 | static void | |
91 | rtype2howto (cache_ptr, dst) | |
92 | arelent *cache_ptr; | |
93 | struct internal_reloc *dst; | |
94 | { | |
95 | switch (dst -> r_type) | |
96 | { | |
69f3f9f7 | 97 | default: abort (); break; |
4507d858 FF |
98 | case R_RELLONG: cache_ptr -> howto = tic80_howto_table + 0; break; |
99 | case R_MPPCR: cache_ptr -> howto = tic80_howto_table + 1; break; | |
69f3f9f7 | 100 | case R_ABS: cache_ptr -> howto = tic80_howto_table + 2; break; |
4507d858 FF |
101 | } |
102 | } | |
103 | ||
104 | #define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst) | |
105 | #define coff_rtype_to_howto coff_tic80_rtype_to_howto | |
106 | ||
107 | static reloc_howto_type * | |
108 | coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp) | |
109 | bfd *abfd; | |
110 | asection *sec; | |
111 | struct internal_reloc *rel; | |
112 | struct coff_link_hash_entry *h; | |
113 | struct internal_syment *sym; | |
114 | bfd_vma *addendp; | |
115 | { | |
116 | arelent genrel; | |
117 | ||
118 | if (rel -> r_symndx == -1 && addendp != NULL) | |
119 | { | |
120 | /* This is a TI "internal relocation", which means that the relocation | |
121 | amount is the amount by which the current section is being relocated | |
122 | in the output section. */ | |
123 | *addendp = (sec -> output_section -> vma + sec -> output_offset) - sec -> vma; | |
124 | } | |
125 | RTYPE2HOWTO (&genrel, rel); | |
126 | return genrel.howto; | |
127 | } | |
5a608f5b FF |
128 | |
129 | #ifndef BADMAG | |
130 | #define BADMAG(x) TIC80BADMAG(x) | |
131 | #endif | |
132 | ||
133 | #define TIC80 1 /* Customize coffcode.h */ | |
134 | #include "coffcode.h" | |
135 | ||
136 | const bfd_target | |
137 | #ifdef TARGET_SYM | |
138 | TARGET_SYM = | |
139 | #else | |
140 | tic80coff_vec = | |
141 | #endif | |
142 | { | |
143 | #ifdef TARGET_NAME | |
144 | TARGET_NAME, | |
145 | #else | |
146 | "coff-tic80", /* name */ | |
147 | #endif | |
148 | bfd_target_coff_flavour, | |
0716c2e9 FF |
149 | BFD_ENDIAN_LITTLE, /* data byte order is little (arch supports both) */ |
150 | BFD_ENDIAN_LITTLE, /* header byte order is little */ | |
5a608f5b FF |
151 | |
152 | (HAS_RELOC | EXEC_P | /* object flags */ | |
153 | HAS_LINENO | HAS_DEBUG | | |
154 | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), | |
155 | ||
156 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
157 | #ifdef NAMES_HAVE_UNDERSCORE | |
158 | '_', | |
159 | #else | |
160 | 0, /* leading underscore */ | |
161 | #endif | |
162 | '/', /* ar_pad_char */ | |
163 | 15, /* ar_max_namelen */ | |
4507d858 FF |
164 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, |
165 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
166 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
0716c2e9 FF |
167 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, |
168 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
169 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ | |
5a608f5b FF |
170 | |
171 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
172 | bfd_generic_archive_p, _bfd_dummy_target}, | |
173 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
174 | bfd_false}, | |
175 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
176 | _bfd_write_archive_contents, bfd_false}, | |
177 | ||
178 | BFD_JUMP_TABLE_GENERIC (coff), | |
179 | BFD_JUMP_TABLE_COPY (coff), | |
180 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
181 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
182 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
183 | BFD_JUMP_TABLE_RELOCS (coff), | |
184 | BFD_JUMP_TABLE_WRITE (coff), | |
185 | BFD_JUMP_TABLE_LINK (coff), | |
186 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
187 | ||
188 | COFF_SWAP_TABLE | |
189 | }; |