Commit | Line | Data |
---|---|---|
81635ce4 | 1 | /* BFD back-end for TMS320C54X coff binaries. |
f4ffd778 | 2 | Copyright 1999, 2000, 2001 Free Software Foundation, Inc. |
a44f2895 | 3 | Contributed by Timothy Wall (twall@cygnus.com) |
81635ce4 TW |
4 | |
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | #include "bfd.h" | |
23 | #include "sysdep.h" | |
24 | #include "libbfd.h" | |
25 | #include "bfdlink.h" | |
26 | #include "coff/tic54x.h" | |
27 | #include "coff/internal.h" | |
28 | #include "libcoff.h" | |
29 | ||
f4ffd778 | 30 | #undef F_LSYMS |
81635ce4 TW |
31 | #define F_LSYMS F_LSYMS_TICOFF |
32 | ||
f4ffd778 NC |
33 | static void tic54x_reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *)); |
34 | static bfd_reloc_status_type tic54x_relocation PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
35 | static boolean tic54x_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); | |
36 | static reloc_howto_type * coff_tic54x_rtype_to_howto PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *)); | |
37 | static bfd_vma tic54x_getl32 PARAMS ((const bfd_byte *)); | |
38 | static void tic54x_putl32 PARAMS ((bfd_vma, bfd_byte *)); | |
39 | static bfd_signed_vma tic54x_getl_signed_32 PARAMS ((const bfd_byte *)); | |
40 | static boolean tic54x_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigned long)); | |
41 | static reloc_howto_type * tic54x_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
42 | static void tic54x_lookup_howto PARAMS ((arelent *, struct internal_reloc *)); | |
43 | static boolean ticoff0_bad_format_hook PARAMS ((bfd *, PTR)); | |
44 | static boolean ticoff1_bad_format_hook PARAMS ((bfd *, PTR)); | |
45 | static boolean ticoff_bfd_is_local_label_name PARAMS ((bfd *, const char *)); | |
46 | ||
47 | /* 32-bit operations | |
48 | The octet order is screwy. words are LSB first (LS octet, actually), but | |
49 | longwords are MSW first. For example, 0x12345678 is encoded 0x5678 in the | |
50 | first word and 0x1234 in the second. When looking at the data as stored in | |
51 | the COFF file, you would see the octets ordered as 0x78, 0x56, 0x34, 0x12. | |
52 | Don't bother with 64-bits, as there aren't any. */ | |
53 | ||
81635ce4 | 54 | static bfd_vma |
f4ffd778 NC |
55 | tic54x_getl32 (addr) |
56 | const bfd_byte *addr; | |
81635ce4 TW |
57 | { |
58 | unsigned long v; | |
f4ffd778 NC |
59 | |
60 | v = (unsigned long) addr[2]; | |
81635ce4 TW |
61 | v |= (unsigned long) addr[3] << 8; |
62 | v |= (unsigned long) addr[0] << 16; | |
63 | v |= (unsigned long) addr[1] << 24; | |
64 | return (bfd_vma) v; | |
65 | } | |
66 | ||
67 | static void | |
68 | tic54x_putl32 (data, addr) | |
69 | bfd_vma data; | |
f4ffd778 | 70 | bfd_byte *addr; |
81635ce4 TW |
71 | { |
72 | addr[2] = (bfd_byte)data; | |
6e301b2b KH |
73 | addr[3] = (bfd_byte) (data >> 8); |
74 | addr[0] = (bfd_byte) (data >> 16); | |
75 | addr[1] = (bfd_byte) (data >> 24); | |
81635ce4 TW |
76 | } |
77 | ||
78 | bfd_signed_vma | |
79 | tic54x_getl_signed_32 (addr) | |
80 | register const bfd_byte *addr; | |
81 | { | |
82 | unsigned long v; | |
83 | ||
f4ffd778 | 84 | v = (unsigned long) addr[2]; |
81635ce4 TW |
85 | v |= (unsigned long) addr[3] << 8; |
86 | v |= (unsigned long) addr[0] << 16; | |
87 | v |= (unsigned long) addr[1] << 24; | |
88 | #define COERCE32(x) \ | |
89 | ((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000)) | |
90 | return COERCE32 (v); | |
91 | } | |
92 | ||
b9af77f5 TW |
93 | #define coff_get_section_load_page bfd_ticoff_get_section_load_page |
94 | #define coff_set_section_load_page bfd_ticoff_set_section_load_page | |
95 | ||
cbfe05c4 | 96 | void |
b9af77f5 TW |
97 | bfd_ticoff_set_section_load_page (sect, page) |
98 | asection *sect; | |
99 | int page; | |
100 | { | |
101 | sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page); | |
102 | } | |
103 | ||
b9af77f5 TW |
104 | int |
105 | bfd_ticoff_get_section_load_page (sect) | |
106 | asection *sect; | |
107 | { | |
108 | int page; | |
109 | ||
cbfe05c4 | 110 | /* Provide meaningful defaults for predefined sections. */ |
b9af77f5 TW |
111 | if (sect == &bfd_com_section) |
112 | page = PG_DATA; | |
113 | ||
114 | else if (sect == &bfd_und_section | |
115 | || sect == &bfd_abs_section | |
116 | || sect == &bfd_ind_section) | |
117 | page = PG_PROG; | |
118 | ||
119 | else | |
120 | page = FLAG_TO_PG (sect->lma); | |
121 | ||
122 | return page; | |
123 | } | |
124 | ||
125 | /* Set the architecture appropriately. Allow unkown architectures | |
cbfe05c4 | 126 | (e.g. binary). */ |
f4ffd778 | 127 | |
b9af77f5 TW |
128 | static boolean |
129 | tic54x_set_arch_mach (abfd, arch, machine) | |
130 | bfd *abfd; | |
131 | enum bfd_architecture arch; | |
132 | unsigned long machine; | |
133 | { | |
134 | if (arch == bfd_arch_unknown) | |
135 | arch = bfd_arch_tic54x; | |
136 | ||
137 | else if (arch != bfd_arch_tic54x) | |
138 | return false; | |
139 | ||
140 | return bfd_default_set_arch_mach (abfd, arch, machine); | |
141 | } | |
142 | ||
81635ce4 | 143 | static bfd_reloc_status_type |
cbfe05c4 | 144 | tic54x_relocation (abfd, reloc_entry, symbol, data, input_section, |
81635ce4 TW |
145 | output_bfd, error_message) |
146 | bfd *abfd ATTRIBUTE_UNUSED; | |
147 | arelent *reloc_entry; | |
148 | asymbol *symbol ATTRIBUTE_UNUSED; | |
149 | PTR data ATTRIBUTE_UNUSED; | |
150 | asection *input_section; | |
151 | bfd *output_bfd; | |
152 | char **error_message ATTRIBUTE_UNUSED; | |
153 | { | |
81635ce4 TW |
154 | if (output_bfd != (bfd *) NULL) |
155 | { | |
156 | /* This is a partial relocation, and we want to apply the | |
157 | relocation to the reloc entry rather than the raw data. | |
158 | Modify the reloc inplace to reflect what we now know. */ | |
159 | reloc_entry->address += input_section->output_offset; | |
160 | return bfd_reloc_ok; | |
161 | } | |
162 | return bfd_reloc_continue; | |
163 | } | |
164 | ||
165 | reloc_howto_type tic54x_howto_table[] = | |
f4ffd778 NC |
166 | { |
167 | /* type,rightshift,size (0=byte, 1=short, 2=long), | |
168 | bit size, pc_relative, bitpos, dont complain_on_overflow, | |
169 | special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset. */ | |
170 | ||
171 | /* NORMAL BANK */ | |
172 | /* 16-bit direct reference to symbol's address. */ | |
173 | HOWTO (R_RELWORD,0,1,16,false,0,complain_overflow_dont, | |
174 | tic54x_relocation,"REL16",false,0xFFFF,0xFFFF,false), | |
175 | ||
176 | /* 7 LSBs of an address */ | |
177 | HOWTO (R_PARTLS7,0,1,7,false,0,complain_overflow_dont, | |
178 | tic54x_relocation,"LS7",false,0x007F,0x007F,false), | |
179 | ||
180 | /* 9 MSBs of an address */ | |
181 | /* TI assembler doesn't shift its encoding, and is thus incompatible */ | |
182 | HOWTO (R_PARTMS9,7,1,9,false,0,complain_overflow_dont, | |
183 | tic54x_relocation,"MS9",false,0x01FF,0x01FF,false), | |
184 | ||
185 | /* 23-bit relocation */ | |
186 | HOWTO (R_EXTWORD,0,2,23,false,0,complain_overflow_dont, | |
187 | tic54x_relocation,"RELEXT",false,0x7FFFFF,0x7FFFFF,false), | |
188 | ||
189 | /* 16 bits of 23-bit extended address */ | |
190 | HOWTO (R_EXTWORD16,0,1,16,false,0,complain_overflow_dont, | |
191 | tic54x_relocation,"RELEXT16",false,0x7FFFFF,0x7FFFFF,false), | |
192 | ||
193 | /* upper 7 bits of 23-bit extended address */ | |
194 | HOWTO (R_EXTWORDMS7,16,1,7,false,0,complain_overflow_dont, | |
195 | tic54x_relocation,"RELEXTMS7",false,0x7F,0x7F,false), | |
196 | ||
197 | /* ABSOLUTE BANK */ | |
198 | /* 16-bit direct reference to symbol's address, absolute */ | |
199 | HOWTO (R_RELWORD,0,1,16,false,0,complain_overflow_dont, | |
200 | tic54x_relocation,"AREL16",false,0xFFFF,0xFFFF,false), | |
201 | ||
202 | /* 7 LSBs of an address, absolute */ | |
203 | HOWTO (R_PARTLS7,0,1,7,false,0,complain_overflow_dont, | |
204 | tic54x_relocation,"ALS7",false,0x007F,0x007F,false), | |
205 | ||
206 | /* 9 MSBs of an address, absolute */ | |
207 | /* TI assembler doesn't shift its encoding, and is thus incompatible */ | |
208 | HOWTO (R_PARTMS9,7,1,9,false,0,complain_overflow_dont, | |
209 | tic54x_relocation,"AMS9",false,0x01FF,0x01FF,false), | |
210 | ||
211 | /* 23-bit direct reference, absolute */ | |
212 | HOWTO (R_EXTWORD,0,2,23,false,0,complain_overflow_dont, | |
213 | tic54x_relocation,"ARELEXT",false,0x7FFFFF,0x7FFFFF,false), | |
214 | ||
215 | /* 16 bits of 23-bit extended address, absolute */ | |
216 | HOWTO (R_EXTWORD16,0,1,16,false,0,complain_overflow_dont, | |
217 | tic54x_relocation,"ARELEXT16",false,0x7FFFFF,0x7FFFFF,false), | |
218 | ||
219 | /* upper 7 bits of 23-bit extended address, absolute */ | |
220 | HOWTO (R_EXTWORDMS7,16,1,7,false,0,complain_overflow_dont, | |
221 | tic54x_relocation,"ARELEXTMS7",false,0x7F,0x7F,false), | |
222 | ||
223 | /* 32-bit relocation exclusively for stabs */ | |
224 | HOWTO (R_RELLONG,0,2,32,false,0,complain_overflow_dont, | |
225 | tic54x_relocation,"STAB",false,0xFFFFFFFF,0xFFFFFFFF,false), | |
226 | }; | |
81635ce4 TW |
227 | |
228 | #define coff_bfd_reloc_type_lookup tic54x_coff_reloc_type_lookup | |
229 | ||
230 | /* For the case statement use the code values used tc_gen_reloc (defined in | |
f4ffd778 NC |
231 | bfd/reloc.c) to map to the howto table entries. */ |
232 | ||
81635ce4 TW |
233 | reloc_howto_type * |
234 | tic54x_coff_reloc_type_lookup (abfd, code) | |
235 | bfd *abfd ATTRIBUTE_UNUSED; | |
236 | bfd_reloc_code_real_type code; | |
237 | { | |
238 | switch (code) | |
239 | { | |
240 | case BFD_RELOC_16: | |
241 | return &tic54x_howto_table[0]; | |
242 | case BFD_RELOC_TIC54X_PARTLS7: | |
243 | return &tic54x_howto_table[1]; | |
244 | case BFD_RELOC_TIC54X_PARTMS9: | |
245 | return &tic54x_howto_table[2]; | |
246 | case BFD_RELOC_TIC54X_23: | |
247 | return &tic54x_howto_table[3]; | |
248 | case BFD_RELOC_TIC54X_16_OF_23: | |
249 | return &tic54x_howto_table[4]; | |
250 | case BFD_RELOC_TIC54X_MS7_OF_23: | |
251 | return &tic54x_howto_table[5]; | |
252 | case BFD_RELOC_32: | |
253 | return &tic54x_howto_table[12]; | |
254 | default: | |
255 | return (reloc_howto_type *) NULL; | |
256 | } | |
257 | } | |
258 | ||
cbfe05c4 | 259 | /* Code to turn a r_type into a howto ptr, uses the above howto table. |
f4ffd778 NC |
260 | Called after some initial checking by the tic54x_rtype_to_howto fn below. */ |
261 | ||
81635ce4 TW |
262 | static void |
263 | tic54x_lookup_howto (internal, dst) | |
264 | arelent *internal; | |
265 | struct internal_reloc *dst; | |
266 | { | |
267 | unsigned i; | |
268 | int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0; | |
f4ffd778 | 269 | |
81635ce4 TW |
270 | for (i = 0; i < sizeof tic54x_howto_table/sizeof tic54x_howto_table[0]; i++) |
271 | { | |
272 | if (tic54x_howto_table[i].type == dst->r_type) | |
273 | { | |
274 | internal->howto = tic54x_howto_table + i + bank; | |
275 | return; | |
276 | } | |
277 | } | |
278 | ||
279 | (*_bfd_error_handler) (_("Unrecognized reloc type 0x%x"), | |
280 | (unsigned int) dst->r_type); | |
cbfe05c4 | 281 | abort (); |
81635ce4 TW |
282 | } |
283 | ||
284 | #define RELOC_PROCESSING(RELENT,RELOC,SYMS,ABFD,SECT)\ | |
285 | tic54x_reloc_processing(RELENT,RELOC,SYMS,ABFD,SECT) | |
286 | ||
81635ce4 TW |
287 | #define coff_rtype_to_howto coff_tic54x_rtype_to_howto |
288 | ||
289 | static reloc_howto_type * | |
290 | coff_tic54x_rtype_to_howto (abfd, sec, rel, h, sym, addendp) | |
291 | bfd *abfd ATTRIBUTE_UNUSED; | |
292 | asection *sec; | |
293 | struct internal_reloc *rel; | |
294 | struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; | |
295 | struct internal_syment *sym ATTRIBUTE_UNUSED; | |
296 | bfd_vma *addendp; | |
297 | { | |
298 | arelent genrel; | |
299 | ||
300 | if (rel->r_symndx == -1 && addendp != NULL) | |
301 | { | |
302 | /* This is a TI "internal relocation", which means that the relocation | |
303 | amount is the amount by which the current section is being relocated | |
cbfe05c4 | 304 | in the output section. */ |
81635ce4 TW |
305 | *addendp = (sec->output_section->vma + sec->output_offset) - sec->vma; |
306 | } | |
307 | ||
308 | tic54x_lookup_howto (&genrel, rel); | |
309 | ||
310 | return genrel.howto; | |
311 | } | |
312 | ||
313 | static boolean | |
314 | ticoff0_bad_format_hook (abfd, filehdr) | |
315 | bfd * abfd ATTRIBUTE_UNUSED; | |
316 | PTR filehdr; | |
317 | { | |
318 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | |
319 | ||
320 | if (COFF0_BADMAG (*internal_f)) | |
321 | return false; | |
322 | ||
323 | return true; | |
324 | } | |
325 | ||
326 | static boolean | |
327 | ticoff1_bad_format_hook (abfd, filehdr) | |
328 | bfd * abfd ATTRIBUTE_UNUSED; | |
329 | PTR filehdr; | |
330 | { | |
331 | struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; | |
332 | ||
333 | if (COFF1_BADMAG (*internal_f)) | |
334 | return false; | |
335 | ||
336 | return true; | |
337 | } | |
338 | ||
f4ffd778 NC |
339 | /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local |
340 | labels. */ | |
341 | ||
cbfe05c4 | 342 | static boolean |
81635ce4 TW |
343 | ticoff_bfd_is_local_label_name (abfd, name) |
344 | bfd *abfd ATTRIBUTE_UNUSED; | |
345 | const char *name; | |
346 | { | |
347 | if (TICOFF_LOCAL_LABEL_P(name)) | |
348 | return true; | |
349 | return false; | |
350 | } | |
351 | ||
352 | #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name | |
353 | ||
cbfe05c4 | 354 | /* Customize coffcode.h; the default coff_ functions are set up to use COFF2; |
81635ce4 TW |
355 | coff_bad_format_hook uses BADMAG, so set that for COFF2. The COFF1 |
356 | and COFF0 vectors use custom _bad_format_hook procs instead of setting | |
f4ffd778 | 357 | BADMAG. */ |
81635ce4 TW |
358 | #define BADMAG(x) COFF2_BADMAG(x) |
359 | #include "coffcode.h" | |
360 | ||
b9af77f5 TW |
361 | static boolean |
362 | tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do) | |
363 | bfd *abfd; | |
364 | sec_ptr section; | |
365 | PTR location; | |
366 | file_ptr offset; | |
367 | bfd_size_type bytes_to_do; | |
368 | { | |
cbfe05c4 | 369 | return coff_set_section_contents (abfd, section, location, |
b9af77f5 TW |
370 | offset, bytes_to_do); |
371 | } | |
372 | ||
81635ce4 TW |
373 | static void |
374 | tic54x_reloc_processing (relent, reloc, symbols, abfd, section) | |
375 | arelent *relent; | |
376 | struct internal_reloc *reloc; | |
377 | asymbol **symbols; | |
378 | bfd *abfd; | |
379 | asection *section; | |
380 | { | |
381 | asymbol *ptr; | |
382 | ||
383 | relent->address = reloc->r_vaddr; | |
cbfe05c4 | 384 | |
81635ce4 TW |
385 | if (reloc->r_symndx != -1) |
386 | { | |
387 | if (reloc->r_symndx < 0 || reloc->r_symndx >= obj_conv_table_size (abfd)) | |
388 | { | |
389 | (*_bfd_error_handler) | |
390 | (_("%s: warning: illegal symbol index %ld in relocs"), | |
8f615d07 | 391 | bfd_archive_filename (abfd), reloc->r_symndx); |
81635ce4 TW |
392 | relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; |
393 | ptr = NULL; | |
394 | } | |
395 | else | |
396 | { | |
397 | relent->sym_ptr_ptr = (symbols | |
398 | + obj_convert (abfd)[reloc->r_symndx]); | |
399 | ptr = *(relent->sym_ptr_ptr); | |
400 | } | |
401 | } | |
402 | else | |
403 | { | |
404 | relent->sym_ptr_ptr = section->symbol_ptr_ptr; | |
405 | ptr = *(relent->sym_ptr_ptr); | |
406 | } | |
cbfe05c4 | 407 | |
81635ce4 TW |
408 | /* The symbols definitions that we have read in have been |
409 | relocated as if their sections started at 0. But the offsets | |
410 | refering to the symbols in the raw data have not been | |
411 | modified, so we have to have a negative addend to compensate. | |
cbfe05c4 | 412 | |
f4ffd778 | 413 | Note that symbols which used to be common must be left alone. */ |
cbfe05c4 | 414 | |
f4ffd778 | 415 | /* Calculate any reloc addend by looking at the symbol. */ |
81635ce4 | 416 | CALC_ADDEND (abfd, ptr, *reloc, relent); |
cbfe05c4 | 417 | |
81635ce4 TW |
418 | relent->address -= section->vma; |
419 | /* !! relent->section = (asection *) NULL;*/ | |
cbfe05c4 | 420 | |
f4ffd778 | 421 | /* Fill in the relent->howto field from reloc->r_type. */ |
81635ce4 TW |
422 | tic54x_lookup_howto (relent, reloc); |
423 | } | |
424 | ||
f4ffd778 | 425 | /* COFF0 differs in file/section header size and relocation entry size. */ |
dc810e39 | 426 | static const bfd_coff_backend_data ticoff0_swap_table = |
f4ffd778 NC |
427 | { |
428 | coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, | |
429 | coff_SWAP_aux_out, coff_SWAP_sym_out, | |
430 | coff_SWAP_lineno_out, coff_SWAP_reloc_out, | |
431 | coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out, | |
432 | coff_SWAP_scnhdr_out, | |
433 | FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN, | |
81635ce4 | 434 | #ifdef COFF_LONG_FILENAMES |
f4ffd778 | 435 | true, |
81635ce4 | 436 | #else |
f4ffd778 | 437 | false, |
81635ce4 TW |
438 | #endif |
439 | #ifdef COFF_LONG_SECTION_NAMES | |
f4ffd778 | 440 | true, |
81635ce4 | 441 | #else |
f4ffd778 | 442 | false, |
7f6d05e8 CP |
443 | #endif |
444 | #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS | |
f4ffd778 | 445 | true, |
7f6d05e8 | 446 | #else |
f4ffd778 | 447 | false, |
7f6d05e8 CP |
448 | #endif |
449 | #ifdef COFF_DEBUG_STRING_WIDE_PREFIX | |
f4ffd778 | 450 | 4, |
7f6d05e8 | 451 | #else |
f4ffd778 | 452 | 2, |
81635ce4 | 453 | #endif |
f4ffd778 NC |
454 | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
455 | coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, | |
456 | coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook, | |
457 | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, | |
458 | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, | |
459 | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, | |
460 | coff_classify_symbol, coff_compute_section_file_positions, | |
461 | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, | |
462 | coff_adjust_symndx, coff_link_add_one_symbol, | |
463 | coff_link_output_has_begun, coff_final_link_postscript | |
464 | }; | |
465 | ||
466 | /* COFF1 differs in section header size. */ | |
dc810e39 | 467 | static const bfd_coff_backend_data ticoff1_swap_table = |
f4ffd778 NC |
468 | { |
469 | coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, | |
470 | coff_SWAP_aux_out, coff_SWAP_sym_out, | |
471 | coff_SWAP_lineno_out, coff_SWAP_reloc_out, | |
472 | coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out, | |
473 | coff_SWAP_scnhdr_out, | |
474 | FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN, | |
81635ce4 | 475 | #ifdef COFF_LONG_FILENAMES |
f4ffd778 | 476 | true, |
81635ce4 | 477 | #else |
f4ffd778 | 478 | false, |
81635ce4 TW |
479 | #endif |
480 | #ifdef COFF_LONG_SECTION_NAMES | |
f4ffd778 | 481 | true, |
81635ce4 | 482 | #else |
f4ffd778 | 483 | false, |
81635ce4 | 484 | #endif |
f4ffd778 | 485 | COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
7f6d05e8 | 486 | #ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
f4ffd778 | 487 | true, |
7f6d05e8 | 488 | #else |
f4ffd778 | 489 | false, |
7f6d05e8 CP |
490 | #endif |
491 | #ifdef COFF_DEBUG_STRING_WIDE_PREFIX | |
f4ffd778 | 492 | 4, |
7f6d05e8 | 493 | #else |
f4ffd778 | 494 | 2, |
7f6d05e8 | 495 | #endif |
f4ffd778 NC |
496 | coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
497 | coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook, | |
498 | coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, | |
499 | coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, | |
500 | coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, | |
501 | coff_classify_symbol, coff_compute_section_file_positions, | |
502 | coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, | |
503 | coff_adjust_symndx, coff_link_add_one_symbol, | |
504 | coff_link_output_has_begun, coff_final_link_postscript | |
505 | }; | |
506 | ||
507 | /* TI COFF v0, DOS tools (little-endian headers). */ | |
81635ce4 | 508 | const bfd_target tic54x_coff0_vec = |
f4ffd778 NC |
509 | { |
510 | "coff0-c54x", /* name */ | |
511 | bfd_target_coff_flavour, | |
512 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
513 | BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ | |
514 | ||
515 | (HAS_RELOC | EXEC_P | /* object flags */ | |
516 | HAS_LINENO | HAS_DEBUG | | |
517 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
518 | ||
519 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
520 | '_', /* leading symbol underscore */ | |
521 | '/', /* ar_pad_char */ | |
522 | 15, /* ar_max_namelen */ | |
523 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
524 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
525 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
526 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
527 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
528 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ | |
529 | ||
530 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
531 | bfd_generic_archive_p, _bfd_dummy_target}, | |
532 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
533 | bfd_false}, | |
534 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
535 | _bfd_write_archive_contents, bfd_false}, | |
536 | ||
537 | BFD_JUMP_TABLE_GENERIC (coff), | |
538 | BFD_JUMP_TABLE_COPY (coff), | |
539 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
540 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
541 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
542 | BFD_JUMP_TABLE_RELOCS (coff), | |
543 | BFD_JUMP_TABLE_WRITE (tic54x), | |
544 | BFD_JUMP_TABLE_LINK (coff), | |
545 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
546 | NULL, | |
547 | ||
548 | (PTR) & ticoff0_swap_table | |
549 | }; | |
550 | ||
551 | /* TI COFF v0, SPARC tools (big-endian headers). */ | |
81635ce4 | 552 | const bfd_target tic54x_coff0_beh_vec = |
f4ffd778 NC |
553 | { |
554 | "coff0-beh-c54x", /* name */ | |
555 | bfd_target_coff_flavour, | |
556 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
557 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
558 | ||
559 | (HAS_RELOC | EXEC_P | /* object flags */ | |
560 | HAS_LINENO | HAS_DEBUG | | |
561 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
562 | ||
563 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
564 | '_', /* leading symbol underscore */ | |
565 | '/', /* ar_pad_char */ | |
566 | 15, /* ar_max_namelen */ | |
567 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
568 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
569 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
570 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
571 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
572 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
573 | ||
574 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
575 | bfd_generic_archive_p, _bfd_dummy_target}, | |
576 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
577 | bfd_false}, | |
578 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
579 | _bfd_write_archive_contents, bfd_false}, | |
580 | ||
581 | BFD_JUMP_TABLE_GENERIC (coff), | |
582 | BFD_JUMP_TABLE_COPY (coff), | |
583 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
584 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
585 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
586 | BFD_JUMP_TABLE_RELOCS (coff), | |
587 | BFD_JUMP_TABLE_WRITE (tic54x), | |
588 | BFD_JUMP_TABLE_LINK (coff), | |
589 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
590 | ||
591 | & tic54x_coff0_vec, | |
592 | ||
593 | (PTR) & ticoff0_swap_table | |
594 | }; | |
595 | ||
596 | /* TI COFF v1, DOS tools (little-endian headers). */ | |
81635ce4 | 597 | const bfd_target tic54x_coff1_vec = |
f4ffd778 NC |
598 | { |
599 | "coff1-c54x", /* name */ | |
600 | bfd_target_coff_flavour, | |
601 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
602 | BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ | |
603 | ||
604 | (HAS_RELOC | EXEC_P | /* object flags */ | |
605 | HAS_LINENO | HAS_DEBUG | | |
606 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
607 | ||
608 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
609 | '_', /* leading symbol underscore */ | |
610 | '/', /* ar_pad_char */ | |
611 | 15, /* ar_max_namelen */ | |
612 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
613 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
614 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
615 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
616 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
617 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ | |
618 | ||
619 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
620 | bfd_generic_archive_p, _bfd_dummy_target}, | |
621 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
622 | bfd_false}, | |
623 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
624 | _bfd_write_archive_contents, bfd_false}, | |
625 | ||
626 | BFD_JUMP_TABLE_GENERIC (coff), | |
627 | BFD_JUMP_TABLE_COPY (coff), | |
628 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
629 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
630 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
631 | BFD_JUMP_TABLE_RELOCS (coff), | |
632 | BFD_JUMP_TABLE_WRITE (tic54x), | |
633 | BFD_JUMP_TABLE_LINK (coff), | |
634 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
635 | ||
636 | & tic54x_coff0_beh_vec, | |
637 | ||
638 | (PTR) & ticoff1_swap_table | |
81635ce4 TW |
639 | }; |
640 | ||
f4ffd778 | 641 | /* TI COFF v1, SPARC tools (big-endian headers). */ |
81635ce4 | 642 | const bfd_target tic54x_coff1_beh_vec = |
f4ffd778 NC |
643 | { |
644 | "coff1-beh-c54x", /* name */ | |
645 | bfd_target_coff_flavour, | |
646 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
647 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
648 | ||
649 | (HAS_RELOC | EXEC_P | /* object flags */ | |
650 | HAS_LINENO | HAS_DEBUG | | |
651 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
652 | ||
653 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
654 | '_', /* leading symbol underscore */ | |
655 | '/', /* ar_pad_char */ | |
656 | 15, /* ar_max_namelen */ | |
657 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
658 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
659 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
660 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
661 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
662 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
663 | ||
664 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
665 | bfd_generic_archive_p, _bfd_dummy_target}, | |
666 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
667 | bfd_false}, | |
668 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
669 | _bfd_write_archive_contents, bfd_false}, | |
670 | ||
671 | BFD_JUMP_TABLE_GENERIC (coff), | |
672 | BFD_JUMP_TABLE_COPY (coff), | |
673 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
674 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
675 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
676 | BFD_JUMP_TABLE_RELOCS (coff), | |
677 | BFD_JUMP_TABLE_WRITE (tic54x), | |
678 | BFD_JUMP_TABLE_LINK (coff), | |
679 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
680 | ||
681 | & tic54x_coff1_vec, | |
682 | ||
683 | (PTR) & ticoff1_swap_table | |
684 | }; | |
685 | ||
686 | /* TI COFF v2, TI DOS tools output (little-endian headers). */ | |
81635ce4 | 687 | const bfd_target tic54x_coff2_vec = |
f4ffd778 NC |
688 | { |
689 | "coff2-c54x", /* name */ | |
690 | bfd_target_coff_flavour, | |
691 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
692 | BFD_ENDIAN_LITTLE, /* header byte order is little (DOS tools) */ | |
693 | ||
694 | (HAS_RELOC | EXEC_P | /* object flags */ | |
695 | HAS_LINENO | HAS_DEBUG | | |
696 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
697 | ||
698 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
699 | '_', /* leading symbol underscore */ | |
700 | '/', /* ar_pad_char */ | |
701 | 15, /* ar_max_namelen */ | |
702 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
703 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
704 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
705 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
706 | bfd_getl32, bfd_getl_signed_32, bfd_putl32, | |
707 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ | |
708 | ||
709 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
710 | bfd_generic_archive_p, _bfd_dummy_target}, | |
711 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
712 | bfd_false}, | |
713 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
714 | _bfd_write_archive_contents, bfd_false}, | |
715 | ||
716 | BFD_JUMP_TABLE_GENERIC (coff), | |
717 | BFD_JUMP_TABLE_COPY (coff), | |
718 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
719 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
720 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
721 | BFD_JUMP_TABLE_RELOCS (coff), | |
722 | BFD_JUMP_TABLE_WRITE (tic54x), | |
723 | BFD_JUMP_TABLE_LINK (coff), | |
724 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
725 | ||
726 | & tic54x_coff1_beh_vec, | |
727 | ||
728 | COFF_SWAP_TABLE | |
729 | }; | |
730 | ||
731 | /* TI COFF v2, TI SPARC tools output (big-endian headers). */ | |
81635ce4 | 732 | const bfd_target tic54x_coff2_beh_vec = |
f4ffd778 NC |
733 | { |
734 | "coff2-beh-c54x", /* name */ | |
735 | bfd_target_coff_flavour, | |
736 | BFD_ENDIAN_LITTLE, /* data byte order is little */ | |
737 | BFD_ENDIAN_BIG, /* header byte order is big */ | |
738 | ||
739 | (HAS_RELOC | EXEC_P | /* object flags */ | |
740 | HAS_LINENO | HAS_DEBUG | | |
741 | HAS_SYMS | HAS_LOCALS | WP_TEXT ), | |
742 | ||
743 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
744 | '_', /* leading symbol underscore */ | |
745 | '/', /* ar_pad_char */ | |
746 | 15, /* ar_max_namelen */ | |
747 | bfd_getl64, bfd_getl_signed_64, bfd_putl64, | |
748 | tic54x_getl32, tic54x_getl_signed_32, tic54x_putl32, | |
749 | bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ | |
750 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
751 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
752 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
753 | ||
754 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ | |
755 | bfd_generic_archive_p, _bfd_dummy_target}, | |
756 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
757 | bfd_false}, | |
758 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
759 | _bfd_write_archive_contents, bfd_false}, | |
760 | ||
761 | BFD_JUMP_TABLE_GENERIC (coff), | |
762 | BFD_JUMP_TABLE_COPY (coff), | |
763 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
764 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
765 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
766 | BFD_JUMP_TABLE_RELOCS (coff), | |
767 | BFD_JUMP_TABLE_WRITE (tic54x), | |
768 | BFD_JUMP_TABLE_LINK (coff), | |
769 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
770 | ||
771 | & tic54x_coff2_vec, | |
772 | ||
773 | COFF_SWAP_TABLE | |
774 | }; |