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