1 /* BFD back-end for TMS320C30 a.out binaries.
2 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
3 Free Software Foundation, Inc.
4 Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
23 #define TARGET_IS_BIG_ENDIAN_P
24 #define N_HEADER_IN_TEXT(x) 1
25 #define TEXT_START_ADDR 1024
26 #define TARGET_PAGE_SIZE 128
27 #define SEGMENT_SIZE TARGET_PAGE_SIZE
28 #define DEFAULT_ARCH bfd_arch_tic30
31 /* Do not "beautify" the CONCAT* macro args. Traditional C will not
32 remove whitespace added here, and thus will fail to concatenate
34 #define MY(OP) CONCAT2 (tic30_aout_,OP)
35 #define TARGETNAME "a.out-tic30"
36 #define NAME(x,y) CONCAT3 (tic30_aout,_32_,y)
41 #include "aout/aout64.h"
42 #include "aout/stab_gnu.h"
45 #define MY_reloc_howto(BFD, REL, IN, EX, PC) tic30_aout_reloc_howto (BFD, REL, & IN, & EX, & PC)
47 #define MY_final_link_relocate tic30_aout_final_link_relocate
48 #define MY_object_p tic30_aout_object_p
49 #define MY_mkobject NAME (aout,mkobject)
50 #define MY_write_object_contents tic30_aout_write_object_contents
51 #define MY_set_sizes tic30_aout_set_sizes
53 #ifndef MY_exec_hdr_flags
54 #define MY_exec_hdr_flags 1
57 #ifndef MY_backend_data
59 #ifndef MY_zmagic_contiguous
60 #define MY_zmagic_contiguous 0
62 #ifndef MY_text_includes_header
63 #define MY_text_includes_header 0
65 #ifndef MY_entry_is_text_address
66 #define MY_entry_is_text_address 0
68 #ifndef MY_exec_header_not_counted
69 #define MY_exec_header_not_counted 1
71 #ifndef MY_add_dynamic_symbols
72 #define MY_add_dynamic_symbols 0
74 #ifndef MY_add_one_symbol
75 #define MY_add_one_symbol 0
77 #ifndef MY_link_dynamic_object
78 #define MY_link_dynamic_object 0
80 #ifndef MY_write_dynamic_symbol
81 #define MY_write_dynamic_symbol 0
83 #ifndef MY_check_dynamic_reloc
84 #define MY_check_dynamic_reloc 0
86 #ifndef MY_finish_dynamic_link
87 #define MY_finish_dynamic_link 0
91 tic30_aout_set_sizes (bfd *abfd)
93 adata (abfd).page_size = TARGET_PAGE_SIZE;
96 adata (abfd).segment_size = SEGMENT_SIZE;
98 adata (abfd).segment_size = TARGET_PAGE_SIZE;
101 #ifdef ZMAGIC_DISK_BLOCK_SIZE
102 adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
104 adata (abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
107 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
112 static const struct aout_backend_data tic30_aout_backend_data =
114 MY_zmagic_contiguous,
115 MY_text_includes_header,
116 MY_entry_is_text_address,
120 MY_exec_header_not_counted,
121 MY_add_dynamic_symbols,
123 MY_link_dynamic_object,
124 MY_write_dynamic_symbol,
125 MY_check_dynamic_reloc,
126 MY_finish_dynamic_link
128 #define MY_backend_data &tic30_aout_backend_data
131 static reloc_howto_type *
132 tic30_aout_reloc_howto (bfd *, struct reloc_std_external *, int *, int *, int *);
133 static bfd_reloc_status_type
134 tic30_aout_final_link_relocate
135 (reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma, bfd_vma, bfd_vma);
137 /* FIXME: This is wrong. aoutx.h should really only be included by
142 /* This function is used to work out pc-relative offsets for the
143 TMS320C30. The data already placed by md_pcrel_from within gas is
144 useless for a relocation, so we just get the offset value and place
145 a version of this within the object code.
146 tic30_aout_final_link_relocate will then calculate the required
147 relocation to add on to the value in the object code. */
149 static bfd_reloc_status_type
150 tic30_aout_fix_pcrel_16 (bfd *abfd,
151 arelent *reloc_entry,
152 asymbol *symbol ATTRIBUTE_UNUSED,
154 asection *input_section ATTRIBUTE_UNUSED,
155 bfd *output_bfd ATTRIBUTE_UNUSED,
156 char **error_message ATTRIBUTE_UNUSED)
158 bfd_vma relocation = 1;
159 bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1);
161 /* The byte before the location of the fix contains bits 23-16 of
162 the pcrel instruction. Bit 21 is set for a delayed instruction
163 which requires on offset of 3 instead of 1. */
164 if (offset_data & 0x20)
168 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
172 /* This function is used as a callback for 16-bit relocs. This is
173 required for relocations between segments. A line in aoutx.h
174 requires that any relocations for the data section should point to
175 the end of the aligned text section, plus an offset. By default,
176 this does not happen, therefore this function takes care of
179 static bfd_reloc_status_type
180 tic30_aout_fix_16 (bfd *abfd,
181 arelent *reloc_entry,
184 asection *input_section ATTRIBUTE_UNUSED,
186 char **error_message ATTRIBUTE_UNUSED)
190 /* Make sure that the symbol's section is defined. */
191 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
192 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
193 /* Get the size of the input section and turn it into the TMS320C30
194 32-bit address format. */
195 relocation = (symbol->section->vma >> 2);
196 relocation += bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
197 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
201 /* This function does the same thing as tic30_aout_fix_16 except for 32
204 static bfd_reloc_status_type
205 tic30_aout_fix_32 (bfd *abfd,
206 arelent *reloc_entry,
209 asection *input_section ATTRIBUTE_UNUSED,
211 char **error_message ATTRIBUTE_UNUSED)
215 /* Make sure that the symbol's section is defined. */
216 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
217 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
218 /* Get the size of the input section and turn it into the TMS320C30
219 32-bit address format. */
220 relocation = (symbol->section->vma >> 2);
221 relocation += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
222 bfd_put_32 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
226 /* This table lists the relocation types for the TMS320C30. There are
227 only a few relocations required, and all must be divided by 4 (>>
228 2) to get the 32-bit addresses in the format the TMS320C30 likes
230 reloc_howto_type tic30_aout_howto_table[] =
233 HOWTO (1, 2, 1, 16, FALSE, 0, 0, tic30_aout_fix_16,
234 "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
235 HOWTO (2, 2, 2, 24, FALSE, 0, complain_overflow_bitfield, NULL,
236 "24", FALSE, 0x00FFFFFF, 0x00FFFFFF, FALSE),
237 HOWTO (3, 18, 3, 24, FALSE, 0, complain_overflow_bitfield, NULL,
238 "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
239 HOWTO (4, 2, 4, 32, FALSE, 0, complain_overflow_bitfield, tic30_aout_fix_32,
240 "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
241 HOWTO (5, 2, 1, 16, TRUE, 0, complain_overflow_signed,
242 tic30_aout_fix_pcrel_16, "PCREL", TRUE, 0x0000FFFF, 0x0000FFFF, TRUE),
251 static reloc_howto_type *
252 tic30_aout_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
253 bfd_reloc_code_real_type code)
258 case BFD_RELOC_TIC30_LDP:
259 return &tic30_aout_howto_table[3];
261 return &tic30_aout_howto_table[1];
263 return &tic30_aout_howto_table[2];
264 case BFD_RELOC_16_PCREL:
265 return &tic30_aout_howto_table[5];
267 return &tic30_aout_howto_table[4];
273 static reloc_howto_type *
274 tic30_aout_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
280 i < (sizeof (tic30_aout_howto_table)
281 / sizeof (tic30_aout_howto_table[0]));
283 if (tic30_aout_howto_table[i].name != NULL
284 && strcasecmp (tic30_aout_howto_table[i].name, r_name) == 0)
285 return &tic30_aout_howto_table[i];
290 static reloc_howto_type *
291 tic30_aout_reloc_howto (bfd *abfd,
292 struct reloc_std_external *relocs,
297 unsigned int r_length;
298 unsigned int r_pcrel_done;
302 if (bfd_header_big_endian (abfd))
304 *r_index = ((relocs->r_index[0] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[2]);
305 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
306 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
307 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG);
311 *r_index = ((relocs->r_index[2] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[0]);
312 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
313 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
314 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
316 index = r_length + 4 * r_pcrel_done;
317 return tic30_aout_howto_table + index;
320 /* These macros will get 24-bit values from the bfd definition.
322 #define bfd_getb_24(BFD,ADDR) \
323 (bfd_get_8 (BFD, ADDR ) << 16) | \
324 (bfd_get_8 (BFD, ADDR + 1) << 8) | \
325 (bfd_get_8 (BFD, ADDR + 2) )
327 #define bfd_putb_24(BFD,DATA,ADDR) \
328 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 16) & 0xFF), ADDR ); \
329 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 8) & 0xFF), ADDR + 1); \
330 bfd_put_8 (BFD, (bfd_byte) ( DATA & 0xFF), ADDR + 2)
332 /* Set parameters about this a.out file that are machine-dependent.
333 This routine is called from some_aout_object_p just before it returns. */
335 static const bfd_target *
336 tic30_aout_callback (bfd *abfd)
338 struct internal_exec *execp = exec_hdr (abfd);
339 unsigned int arch_align_power;
340 unsigned long arch_align;
342 /* Calculate the file positions of the parts of a newly read aout header. */
343 obj_textsec (abfd)->size = N_TXTSIZE (*execp);
345 /* The virtual memory addresses of the sections. */
346 obj_textsec (abfd)->vma = N_TXTADDR (*execp);
347 obj_datasec (abfd)->vma = N_DATADDR (*execp);
348 obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
350 obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
351 obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
352 obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
354 /* The file offsets of the sections. */
355 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
356 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
358 /* The file offsets of the relocation info. */
359 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
360 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
362 /* The file offsets of the string table and symbol table. */
363 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
364 obj_str_filepos (abfd) = N_STROFF (*execp);
366 /* Determine the architecture and machine type of the object file. */
368 SET_ARCH_MACH (abfd, *execp);
370 bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L);
373 /* Now that we know the architecture, set the alignments of the
374 sections. This is normally done by NAME (aout,new_section_hook),
375 but when the initial sections were created the architecture had
376 not yet been set. However, for backward compatibility, we don't
377 set the alignment power any higher than as required by the size
379 arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
380 arch_align = 1 << arch_align_power;
381 if ((BFD_ALIGN (obj_textsec (abfd)->size, arch_align)
382 == obj_textsec (abfd)->size)
383 && (BFD_ALIGN (obj_datasec (abfd)->size, arch_align)
384 == obj_datasec (abfd)->size)
385 && (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align)
386 == obj_bsssec (abfd)->size))
388 obj_textsec (abfd)->alignment_power = arch_align_power;
389 obj_datasec (abfd)->alignment_power = arch_align_power;
390 obj_bsssec (abfd)->alignment_power = arch_align_power;
395 static bfd_reloc_status_type
396 tic30_aout_relocate_contents (reloc_howto_type *howto,
402 bfd_boolean overflow;
405 relocation = -relocation;
414 x = bfd_get_16 (input_bfd, location);
417 x = bfd_getb_24 (input_bfd, location);
420 x = bfd_get_8 (input_bfd, location);
423 x = bfd_get_32 (input_bfd, location);
429 if (howto->complain_on_overflow != complain_overflow_dont)
432 bfd_signed_vma signed_check;
434 bfd_signed_vma signed_add;
436 if (howto->rightshift == 0)
439 signed_check = (bfd_signed_vma) relocation;
443 check = relocation >> howto->rightshift;
444 if ((bfd_signed_vma) relocation >= 0)
445 signed_check = check;
447 signed_check = (check | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->rightshift)));
449 add = x & howto->src_mask;
451 if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
452 signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
453 if (howto->bitpos == 0)
456 signed_check += signed_add;
460 check += add >> howto->bitpos;
462 signed_check += add >> howto->bitpos;
464 signed_check += ((add >> howto->bitpos) | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->bitpos)));
466 switch (howto->complain_on_overflow)
468 case complain_overflow_signed:
470 bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
471 bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
473 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
477 case complain_overflow_unsigned:
479 bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
481 if (check > reloc_unsigned_max)
485 case complain_overflow_bitfield:
487 bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
489 if ((check & ~reloc_bits) != 0
490 && (((bfd_vma) signed_check & ~reloc_bits)
491 != ((bfd_vma) -1 & ~reloc_bits)))
499 relocation >>= (bfd_vma) howto->rightshift;
500 relocation <<= (bfd_vma) howto->bitpos;
501 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask));
509 bfd_put_16 (input_bfd, x, location);
512 bfd_putb_24 (input_bfd, x, location);
515 bfd_put_8 (input_bfd, x, location);
518 bfd_put_32 (input_bfd, x, location);
521 return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
524 static bfd_reloc_status_type
525 tic30_aout_final_link_relocate (reloc_howto_type *howto,
527 asection *input_section,
535 if (address > bfd_get_section_limit (input_bfd, input_section))
536 return bfd_reloc_outofrange;
538 relocation = value + addend;
539 if (howto->pc_relative)
541 relocation -= (input_section->output_section->vma + input_section->output_offset);
542 if (howto->pcrel_offset)
543 relocation -= address;
545 return tic30_aout_relocate_contents (howto, input_bfd, relocation,
549 /* Finish up the reading of an a.out file header. */
551 static const bfd_target *
552 tic30_aout_object_p (bfd *abfd)
554 struct external_exec exec_bytes; /* Raw exec header from file. */
555 struct internal_exec exec; /* Cleaned-up exec header. */
556 const bfd_target *target;
557 bfd_size_type amt = EXEC_BYTES_SIZE;
559 if (bfd_bread (& exec_bytes, amt, abfd) != amt)
561 if (bfd_get_error () != bfd_error_system_call)
562 bfd_set_error (bfd_error_wrong_format);
567 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
569 exec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
570 #endif /* SWAP_MAGIC */
575 if (!(MACHTYPE_OK (N_MACHTYPE (exec))))
579 NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
582 /* Swap_exec_header_in read in a_info with the wrong byte order. */
583 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
586 target = NAME (aout, some_aout_object_p) (abfd, &exec, tic30_aout_callback);
588 #ifdef ENTRY_CAN_BE_ZERO
589 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
590 means that it isn't obvious if EXEC_P should be set.
591 All of the following must be true for an executable:
592 There must be no relocations, the bfd can be neither an
593 archive nor an archive element, and the file must be executable. */
595 if (exec.a_trsize + exec.a_drsize == 0
596 && bfd_get_format (abfd) == bfd_object && abfd->my_archive == NULL)
600 #define S_IXUSR 0100 /* Execute by owner. */
602 if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
603 abfd->flags |= EXEC_P;
610 /* Copy private section data. This actually does nothing with the
611 sections. It copies the subformat field. We copy it here, because
612 we need to know whether this is a QMAGIC file before we set the
613 section contents, and copy_private_bfd_data is not called until
614 after the section contents have been set. */
617 MY_bfd_copy_private_section_data (bfd *ibfd,
618 asection *isec ATTRIBUTE_UNUSED,
620 asection *osec ATTRIBUTE_UNUSED)
622 if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
623 obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
627 /* Write an object file.
628 Section contents have already been written. We write the
629 file header, symbols, and relocation. */
632 tic30_aout_write_object_contents (bfd *abfd)
634 struct external_exec exec_bytes;
635 struct internal_exec *execp = exec_hdr (abfd);
637 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
640 bfd_size_type text_size; /* Dummy vars. */
643 if (adata (abfd).magic == undecided_magic)
644 NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
646 execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;
647 execp->a_entry = bfd_get_start_address (abfd);
649 execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
650 execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
651 NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
653 if (adata (abfd).exec_bytes_size > 0)
657 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
659 amt = adata (abfd).exec_bytes_size;
660 if (bfd_bwrite (& exec_bytes, amt, abfd) != amt)
664 /* Now write out reloc info, followed by syms and strings. */
665 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
666 && bfd_get_symcount (abfd) != 0)
668 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0)
671 if (!NAME (aout, write_syms) (abfd))
675 if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
677 if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
680 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
682 if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
689 #ifndef MY_final_link_callback
691 /* Callback for the final_link routine to set the section offsets. */
694 MY_final_link_callback (bfd *abfd,
699 struct internal_exec *execp = exec_hdr (abfd);
701 *ptreloff = obj_datasec (abfd)->filepos + execp->a_data;
702 *pdreloff = *ptreloff + execp->a_trsize;
703 *psymoff = *pdreloff + execp->a_drsize;;
708 #ifndef MY_bfd_final_link
710 /* Final link routine. We need to use a call back to get the correct
711 offsets in the output file. */
714 MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
716 struct internal_exec *execp = exec_hdr (abfd);
721 /* Set the executable header size to 0, as we don't want one for an
723 adata (abfd).exec_bytes_size = 0;
724 pos = adata (abfd).exec_bytes_size;
726 vma = info->create_object_symbols_section->vma;
728 obj_textsec (abfd)->filepos = pos;
729 obj_textsec (abfd)->vma = vma;
730 obj_textsec (abfd)->user_set_vma = 1;
731 pos += obj_textsec (abfd)->size;
732 vma += obj_textsec (abfd)->size;
735 if (abfd->flags & D_PAGED)
737 if (info->create_object_symbols_section->next->vma > 0)
738 obj_datasec (abfd)->vma = info->create_object_symbols_section->next->vma;
740 obj_datasec (abfd)->vma = BFD_ALIGN (vma, adata (abfd).segment_size);
743 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
745 if (obj_datasec (abfd)->vma < vma)
746 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
748 obj_datasec (abfd)->user_set_vma = 1;
749 vma = obj_datasec (abfd)->vma;
750 obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size;
751 execp->a_text = vma - obj_textsec (abfd)->vma;
752 obj_textsec (abfd)->size = execp->a_text;
754 /* Since BSS follows data immediately, see if it needs alignment. */
755 vma += obj_datasec (abfd)->size;
756 pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
757 obj_datasec (abfd)->size += pad;
758 pos += obj_datasec (abfd)->size;
759 execp->a_data = obj_datasec (abfd)->size;
762 obj_bsssec (abfd)->vma = vma;
763 obj_bsssec (abfd)->user_set_vma = 1;
765 /* We are fully resized, so don't readjust in final_link. */
766 adata (abfd).magic = z_magic;
768 return NAME (aout, final_link) (abfd, info, MY_final_link_callback);
773 static enum machine_type
774 tic30_aout_machine_type (enum bfd_architecture arch,
775 unsigned long machine ATTRIBUTE_UNUSED,
776 bfd_boolean *unknown)
778 enum machine_type arch_flags;
780 arch_flags = M_UNKNOWN;
789 arch_flags = M_UNKNOWN;
791 if (arch_flags != M_UNKNOWN)
797 tic30_aout_set_arch_mach (bfd *abfd,
798 enum bfd_architecture arch,
799 unsigned long machine)
801 if (!bfd_default_set_arch_mach (abfd, arch, machine))
803 if (arch != bfd_arch_unknown)
806 tic30_aout_machine_type (arch, machine, &unknown);
810 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
811 return (*aout_backend_info (abfd)->set_sizes) (abfd);
814 /* We assume BFD generic archive files. */
815 #ifndef MY_openr_next_archived_file
816 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
818 #ifndef MY_get_elt_at_index
819 #define MY_get_elt_at_index _bfd_generic_get_elt_at_index
821 #ifndef MY_generic_stat_arch_elt
822 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
824 #ifndef MY_slurp_armap
825 #define MY_slurp_armap bfd_slurp_bsd_armap
827 #ifndef MY_slurp_extended_name_table
828 #define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
830 #ifndef MY_construct_extended_name_table
831 #define MY_construct_extended_name_table \
832 _bfd_archive_bsd_construct_extended_name_table
834 #ifndef MY_write_armap
835 #define MY_write_armap bsd_write_armap
837 #ifndef MY_read_ar_hdr
838 #define MY_read_ar_hdr _bfd_generic_read_ar_hdr
840 #ifndef MY_truncate_arname
841 #define MY_truncate_arname bfd_bsd_truncate_arname
843 #ifndef MY_update_armap_timestamp
844 #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
847 /* No core file defined here -- configure in trad-core.c separately. */
848 #ifndef MY_core_file_failing_command
849 #define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
851 #ifndef MY_core_file_failing_signal
852 #define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
854 #ifndef MY_core_file_matches_executable_p
855 #define MY_core_file_matches_executable_p \
856 _bfd_nocore_core_file_matches_executable_p
858 #ifndef MY_core_file_p
859 #define MY_core_file_p _bfd_dummy_target
862 #ifndef MY_bfd_debug_info_start
863 #define MY_bfd_debug_info_start bfd_void
865 #ifndef MY_bfd_debug_info_end
866 #define MY_bfd_debug_info_end bfd_void
868 #ifndef MY_bfd_debug_info_accumulate
869 #define MY_bfd_debug_info_accumulate \
870 (void (*) (bfd*, struct bfd_section *)) bfd_void
873 #ifndef MY_core_file_failing_command
874 #define MY_core_file_failing_command NAME (aout, core_file_failing_command)
876 #ifndef MY_core_file_failing_signal
877 #define MY_core_file_failing_signal NAME (aout, core_file_failing_signal)
879 #ifndef MY_core_file_matches_executable_p
880 #define MY_core_file_matches_executable_p NAME (aout, core_file_matches_executable_p)
882 #ifndef MY_set_section_contents
883 #define MY_set_section_contents NAME (aout, set_section_contents)
885 #ifndef MY_get_section_contents
886 #define MY_get_section_contents aout_32_get_section_contents
888 #ifndef MY_get_section_contents_in_window
889 #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
891 #ifndef MY_new_section_hook
892 #define MY_new_section_hook NAME (aout, new_section_hook)
894 #ifndef MY_get_symtab_upper_bound
895 #define MY_get_symtab_upper_bound NAME (aout, get_symtab_upper_bound)
897 #ifndef MY_canonicalize_symtab
898 #define MY_canonicalize_symtab NAME (aout, canonicalize_symtab)
900 #ifndef MY_get_reloc_upper_bound
901 #define MY_get_reloc_upper_bound NAME (aout, get_reloc_upper_bound)
903 #ifndef MY_canonicalize_reloc
904 #define MY_canonicalize_reloc NAME (aout, canonicalize_reloc)
906 #ifndef MY_make_empty_symbol
907 #define MY_make_empty_symbol NAME (aout, make_empty_symbol)
909 #ifndef MY_print_symbol
910 #define MY_print_symbol NAME (aout, print_symbol)
912 #ifndef MY_get_symbol_info
913 #define MY_get_symbol_info NAME (aout, get_symbol_info)
915 #ifndef MY_get_lineno
916 #define MY_get_lineno NAME (aout, get_lineno)
918 #ifndef MY_set_arch_mach
919 #define MY_set_arch_mach tic30_aout_set_arch_mach
921 #ifndef MY_find_nearest_line
922 #define MY_find_nearest_line NAME (aout, find_nearest_line)
924 #ifndef MY_find_inliner_info
925 #define MY_find_inliner_info _bfd_nosymbols_find_inliner_info
927 #ifndef MY_sizeof_headers
928 #define MY_sizeof_headers NAME (aout, sizeof_headers)
930 #ifndef MY_bfd_get_relocated_section_contents
931 #define MY_bfd_get_relocated_section_contents \
932 bfd_generic_get_relocated_section_contents
934 #ifndef MY_bfd_relax_section
935 #define MY_bfd_relax_section bfd_generic_relax_section
937 #ifndef MY_bfd_gc_sections
938 #define MY_bfd_gc_sections bfd_generic_gc_sections
940 #ifndef MY_bfd_merge_sections
941 #define MY_bfd_merge_sections bfd_generic_merge_sections
943 #ifndef MY_bfd_is_group_section
944 #define MY_bfd_is_group_section bfd_generic_is_group_section
946 #ifndef MY_bfd_discard_group
947 #define MY_bfd_discard_group bfd_generic_discard_group
949 #ifndef MY_section_already_linked
950 #define MY_section_already_linked \
951 _bfd_generic_section_already_linked
953 #ifndef MY_bfd_reloc_type_lookup
954 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
956 #ifndef MY_bfd_reloc_name_lookup
957 #define MY_bfd_reloc_name_lookup tic30_aout_reloc_name_lookup
959 #ifndef MY_bfd_make_debug_symbol
960 #define MY_bfd_make_debug_symbol 0
962 #ifndef MY_read_minisymbols
963 #define MY_read_minisymbols NAME (aout, read_minisymbols)
965 #ifndef MY_minisymbol_to_symbol
966 #define MY_minisymbol_to_symbol NAME (aout, minisymbol_to_symbol)
968 #ifndef MY_bfd_link_hash_table_create
969 #define MY_bfd_link_hash_table_create NAME (aout, link_hash_table_create)
971 #ifndef MY_bfd_link_hash_table_free
972 #define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
974 #ifndef MY_bfd_link_add_symbols
975 #define MY_bfd_link_add_symbols NAME (aout, link_add_symbols)
977 #ifndef MY_bfd_link_just_syms
978 #define MY_bfd_link_just_syms _bfd_generic_link_just_syms
980 #ifndef MY_bfd_link_split_section
981 #define MY_bfd_link_split_section _bfd_generic_link_split_section
984 #ifndef MY_bfd_copy_private_bfd_data
985 #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
988 #ifndef MY_bfd_merge_private_bfd_data
989 #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
992 #ifndef MY_bfd_copy_private_symbol_data
993 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
996 #ifndef MY_bfd_copy_private_header_data
997 #define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
1000 #ifndef MY_bfd_print_private_bfd_data
1001 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
1004 #ifndef MY_bfd_set_private_flags
1005 #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
1008 #ifndef MY_bfd_is_local_label_name
1009 #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
1012 #ifndef MY_bfd_is_target_special_symbol
1013 #define MY_bfd_is_target_special_symbol \
1014 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
1017 #ifndef MY_bfd_free_cached_info
1018 #define MY_bfd_free_cached_info NAME (aout, bfd_free_cached_info)
1021 #ifndef MY_close_and_cleanup
1022 #define MY_close_and_cleanup MY_bfd_free_cached_info
1025 #ifndef MY_get_dynamic_symtab_upper_bound
1026 #define MY_get_dynamic_symtab_upper_bound \
1027 _bfd_nodynamic_get_dynamic_symtab_upper_bound
1029 #ifndef MY_canonicalize_dynamic_symtab
1030 #define MY_canonicalize_dynamic_symtab \
1031 _bfd_nodynamic_canonicalize_dynamic_symtab
1033 #ifndef MY_get_synthetic_symtab
1034 #define MY_get_synthetic_symtab \
1035 _bfd_nodynamic_get_synthetic_symtab
1037 #ifndef MY_get_dynamic_reloc_upper_bound
1038 #define MY_get_dynamic_reloc_upper_bound \
1039 _bfd_nodynamic_get_dynamic_reloc_upper_bound
1041 #ifndef MY_canonicalize_dynamic_reloc
1042 #define MY_canonicalize_dynamic_reloc \
1043 _bfd_nodynamic_canonicalize_dynamic_reloc
1046 /* Aout symbols normally have leading underscores. */
1047 #ifndef MY_symbol_leading_char
1048 #define MY_symbol_leading_char '_'
1051 /* Aout archives normally use spaces for padding. */
1053 #define AR_PAD_CHAR ' '
1056 #ifndef MY_BFD_TARGET
1057 const bfd_target tic30_aout_vec =
1059 TARGETNAME, /* Name. */
1060 bfd_target_aout_flavour,
1061 BFD_ENDIAN_BIG, /* Target byte order (big). */
1062 BFD_ENDIAN_BIG, /* Target headers byte order (big). */
1063 (HAS_RELOC | /* Object flags. */
1064 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1065 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
1066 MY_symbol_leading_char,
1067 AR_PAD_CHAR, /* AR_pad_char. */
1068 15, /* AR_max_namelen. */
1069 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1070 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1071 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
1072 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1073 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1074 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers. */
1075 {_bfd_dummy_target, MY_object_p, /* bfd_check_format. */
1076 bfd_generic_archive_p, MY_core_file_p},
1077 {bfd_false, MY_mkobject, /* bfd_set_format. */
1078 _bfd_generic_mkarchive, bfd_false},
1079 {bfd_false, MY_write_object_contents, /* bfd_write_contents. */
1080 _bfd_write_archive_contents, bfd_false},
1082 BFD_JUMP_TABLE_GENERIC (MY),
1083 BFD_JUMP_TABLE_COPY (MY),
1084 BFD_JUMP_TABLE_CORE (MY),
1085 BFD_JUMP_TABLE_ARCHIVE (MY),
1086 BFD_JUMP_TABLE_SYMBOLS (MY),
1087 BFD_JUMP_TABLE_RELOCS (MY),
1088 BFD_JUMP_TABLE_WRITE (MY),
1089 BFD_JUMP_TABLE_LINK (MY),
1090 BFD_JUMP_TABLE_DYNAMIC (MY),
1096 #endif /* MY_BFD_TARGET */