1 /* BFD back-end for TMS320C30 a.out binaries.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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
22 #define TARGET_IS_BIG_ENDIAN_P
23 #define N_HEADER_IN_TEXT(x) 1
24 #define BYTES_IN_WORD 4
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 #define MY(OP) CAT(tic30_aout_,OP)
32 #define TARGETNAME "a.out-tic30"
33 #define NAME(x,y) CAT3(tic30_aout,_32_,y)
39 #include "aout/aout64.h"
40 #include "aout/stab_gnu.h"
43 static bfd_reloc_status_type tic30_aout_fix_16
44 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
45 static bfd_reloc_status_type tic30_aout_fix_32
46 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
47 static bfd_reloc_status_type tic30_aout_fix_pcrel_16
48 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
49 static reloc_howto_type *tic30_aout_reloc_howto
50 PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
51 static bfd_reloc_status_type tic30_aout_relocate_contents
52 PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *));
53 static bfd_reloc_status_type tic30_aout_final_link_relocate
54 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
56 static const bfd_target *tic30_aout_object_p PARAMS ((bfd *));
57 static boolean tic30_aout_write_object_contents PARAMS ((bfd *));
58 static boolean tic30_aout_set_sizes PARAMS ((bfd *));
60 #define MY_reloc_howto(BFD,REL,IN,EX,PC) tic30_aout_reloc_howto(BFD,REL,&IN,&EX,&PC)
61 #define MY_final_link_relocate tic30_aout_final_link_relocate
62 #define MY_object_p tic30_aout_object_p
63 #define MY_mkobject NAME(aout,mkobject)
64 #define MY_write_object_contents tic30_aout_write_object_contents
65 #define MY_set_sizes tic30_aout_set_sizes
67 #ifndef MY_exec_hdr_flags
68 #define MY_exec_hdr_flags 1
71 #ifndef MY_backend_data
73 #ifndef MY_zmagic_contiguous
74 #define MY_zmagic_contiguous 0
76 #ifndef MY_text_includes_header
77 #define MY_text_includes_header 0
79 #ifndef MY_entry_is_text_address
80 #define MY_entry_is_text_address 0
82 #ifndef MY_exec_header_not_counted
83 #define MY_exec_header_not_counted 1
85 #ifndef MY_add_dynamic_symbols
86 #define MY_add_dynamic_symbols 0
88 #ifndef MY_add_one_symbol
89 #define MY_add_one_symbol 0
91 #ifndef MY_link_dynamic_object
92 #define MY_link_dynamic_object 0
94 #ifndef MY_write_dynamic_symbol
95 #define MY_write_dynamic_symbol 0
97 #ifndef MY_check_dynamic_reloc
98 #define MY_check_dynamic_reloc 0
100 #ifndef MY_finish_dynamic_link
101 #define MY_finish_dynamic_link 0
104 static CONST struct aout_backend_data tic30_aout_backend_data =
106 MY_zmagic_contiguous,
107 MY_text_includes_header,
108 MY_entry_is_text_address,
112 MY_exec_header_not_counted,
113 MY_add_dynamic_symbols,
115 MY_link_dynamic_object,
116 MY_write_dynamic_symbol,
117 MY_check_dynamic_reloc,
118 MY_finish_dynamic_link
120 #define MY_backend_data &tic30_aout_backend_data
123 /* FIXME: This is wrong. aoutx.h should really only be included by
128 /* This table lists the relocation types for the TMS320C30. There are
129 only a few relocations required, and all must be divided by 4 (>>
130 2) to get the 32-bit addresses in the format the TMS320C30 likes
132 reloc_howto_type tic30_aout_howto_table[] =
135 HOWTO (1, 2, 1, 16, false, 0, 0, tic30_aout_fix_16,
136 "16", false, 0x0000FFFF, 0x0000FFFF, false),
137 HOWTO (2, 2, 2, 24, false, 0, complain_overflow_bitfield, NULL,
138 "24", false, 0x00FFFFFF, 0x00FFFFFF, false),
139 HOWTO (3, 18, 3, 24, false, 0, complain_overflow_bitfield, NULL,
140 "LDP", false, 0x00FF0000, 0x000000FF, false),
141 HOWTO (4, 2, 4, 32, false, 0, complain_overflow_bitfield, tic30_aout_fix_32,
142 "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
143 HOWTO (5, 2, 1, 16, true, 0, complain_overflow_signed,
144 tic30_aout_fix_pcrel_16, "PCREL", true, 0x0000FFFF, 0x0000FFFF, true),
152 extern reloc_howto_type *NAME (aout, reloc_type_lookup) ();
155 tic30_aout_reloc_type_lookup (abfd, code)
156 bfd *abfd ATTRIBUTE_UNUSED;
157 bfd_reloc_code_real_type code;
162 case BFD_RELOC_TIC30_LDP:
163 return &tic30_aout_howto_table[3];
165 return &tic30_aout_howto_table[1];
167 return &tic30_aout_howto_table[2];
168 case BFD_RELOC_16_PCREL:
169 return &tic30_aout_howto_table[5];
171 return &tic30_aout_howto_table[4];
173 return (reloc_howto_type *) NULL;
177 static reloc_howto_type *
178 tic30_aout_reloc_howto (abfd, relocs, r_index, r_extern, r_pcrel)
180 struct reloc_std_external *relocs;
185 unsigned int r_length;
186 unsigned int r_pcrel_done;
190 if (bfd_header_big_endian (abfd))
192 *r_index = ((relocs->r_index[0] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[2]);
193 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_BIG));
194 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_BIG));
195 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG);
199 *r_index = ((relocs->r_index[2] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[0]);
200 *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE));
201 r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE));
202 r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
204 index = r_length + 4 * r_pcrel_done;
205 return tic30_aout_howto_table + index;
208 /* This function is used as a callback for 16-bit relocs. This is
209 required for relocations between segments. A line in aoutx.h
210 requires that any relocations for the data section should point to
211 the end of the aligned text section, plus an offset. By default,
212 this does not happen, therefore this function takes care of
215 static bfd_reloc_status_type
216 tic30_aout_fix_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message)
218 arelent *reloc_entry;
221 asection *input_section ATTRIBUTE_UNUSED;
223 char **error_message ATTRIBUTE_UNUSED;
227 /* Make sure that the symbol's section is defined. */
228 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
229 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
230 /* Get the size of the input section and turn it into the TMS320C30
231 32-bit address format. */
232 relocation = (symbol->section->vma >> 2);
233 relocation += bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
234 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
238 /* This function does the same thing as tic30_aout_fix_16 except for 32
241 static bfd_reloc_status_type
242 tic30_aout_fix_32 (abfd, reloc_entry, symbol, data, input_section,
243 output_bfd, error_message)
245 arelent *reloc_entry;
248 asection *input_section ATTRIBUTE_UNUSED;
250 char **error_message ATTRIBUTE_UNUSED;
254 /* Make sure that the symbol's section is defined. */
255 if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
256 return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
257 /* Get the size of the input section and turn it into the TMS320C30
258 32-bit address format. */
259 relocation = (symbol->section->vma >> 2);
260 relocation += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
261 bfd_put_32 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
265 /* This function is used to work out pc-relative offsets for the
266 TMS320C30. The data already placed by md_pcrel_from within gas is
267 useless for a relocation, so we just get the offset value and place
268 a version of this within the object code.
269 tic30_aout_final_link_relocate will then calculate the required
270 relocation to add on to the value in the object code. */
272 static bfd_reloc_status_type
273 tic30_aout_fix_pcrel_16 (abfd, reloc_entry, symbol, data, input_section,
274 output_bfd, error_message)
276 arelent *reloc_entry;
277 asymbol *symbol ATTRIBUTE_UNUSED;
279 asection *input_section ATTRIBUTE_UNUSED;
280 bfd *output_bfd ATTRIBUTE_UNUSED;
281 char **error_message ATTRIBUTE_UNUSED;
283 bfd_vma relocation = 1;
284 bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1);
286 /* The byte before the location of the fix contains bits 23-16 of
287 the pcrel instruction. Bit 21 is set for a delayed instruction
288 which requires on offset of 3 instead of 1. */
289 if (offset_data & 0x20)
293 bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address);
297 /* These macros will get 24-bit values from the bfd definition.
299 #define bfd_getb_24(BFD,ADDR) (bfd_get_8(BFD,ADDR) << 16) | \
300 (bfd_get_8(BFD,ADDR+1) << 8) | \
301 (bfd_get_8(BFD,ADDR+2))
303 #define bfd_putb_24(BFD,DATA,ADDR) bfd_put_8(BFD,(bfd_byte)((DATA >> 16) & 0xFF),ADDR); \
304 bfd_put_8(BFD,(bfd_byte)((DATA >> 8) & 0xFF),ADDR+1); \
305 bfd_put_8(BFD,(bfd_byte)(DATA & 0xFF),ADDR+2)
307 /* Set parameters about this a.out file that are machine-dependent.
308 This routine is called from some_aout_object_p just before it returns. */
310 static const bfd_target *
311 tic30_aout_callback (abfd)
314 struct internal_exec *execp = exec_hdr (abfd);
315 unsigned int arch_align_power;
316 unsigned long arch_align;
318 /* Calculate the file positions of the parts of a newly read aout header */
319 obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
321 /* The virtual memory addresses of the sections */
322 obj_textsec (abfd)->vma = N_TXTADDR (*execp);
323 obj_datasec (abfd)->vma = N_DATADDR (*execp);
324 obj_bsssec (abfd)->vma = N_BSSADDR (*execp);
326 obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
327 obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
328 obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
330 /* The file offsets of the sections */
331 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
332 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
334 /* The file offsets of the relocation info */
335 obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
336 obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
338 /* The file offsets of the string table and symbol table. */
339 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
340 obj_str_filepos (abfd) = N_STROFF (*execp);
342 /* Determine the architecture and machine type of the object file. */
344 SET_ARCH_MACH (abfd, *execp);
346 bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
349 /* Now that we know the architecture, set the alignments of the
350 sections. This is normally done by NAME(aout,new_section_hook),
351 but when the initial sections were created the architecture had
352 not yet been set. However, for backward compatibility, we don't
353 set the alignment power any higher than as required by the size
355 arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
356 arch_align = 1 << arch_align_power;
357 if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
358 == obj_textsec (abfd)->_raw_size)
359 && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
360 == obj_datasec (abfd)->_raw_size)
361 && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
362 == obj_bsssec (abfd)->_raw_size))
364 obj_textsec (abfd)->alignment_power = arch_align_power;
365 obj_datasec (abfd)->alignment_power = arch_align_power;
366 obj_bsssec (abfd)->alignment_power = arch_align_power;
371 static bfd_reloc_status_type
372 tic30_aout_final_link_relocate (howto, input_bfd, input_section, contents,
373 address, value, addend)
374 reloc_howto_type *howto;
376 asection *input_section;
384 if (address > input_section->_raw_size)
385 return bfd_reloc_outofrange;
387 relocation = value + addend;
388 if (howto->pc_relative)
390 relocation -= (input_section->output_section->vma + input_section->output_offset);
391 if (howto->pcrel_offset)
392 relocation -= address;
394 return tic30_aout_relocate_contents (howto, input_bfd, relocation,
398 bfd_reloc_status_type
399 tic30_aout_relocate_contents (howto, input_bfd, relocation, location)
400 reloc_howto_type *howto;
409 relocation = -relocation;
418 x = bfd_get_16 (input_bfd, location);
421 x = bfd_getb_24 (input_bfd, location);
424 x = bfd_get_8 (input_bfd, location);
427 x = bfd_get_32 (input_bfd, location);
431 if (howto->complain_on_overflow != complain_overflow_dont)
434 bfd_signed_vma signed_check;
436 bfd_signed_vma signed_add;
438 if (howto->rightshift == 0)
441 signed_check = (bfd_signed_vma) relocation;
445 check = relocation >> howto->rightshift;
446 if ((bfd_signed_vma) relocation >= 0)
447 signed_check = check;
449 signed_check = (check | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->rightshift)));
451 add = x & howto->src_mask;
453 if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0)
454 signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1;
455 if (howto->bitpos == 0)
458 signed_check += signed_add;
462 check += add >> howto->bitpos;
464 signed_check += add >> howto->bitpos;
466 signed_check += ((add >> howto->bitpos) | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->bitpos)));
468 switch (howto->complain_on_overflow)
470 case complain_overflow_signed:
472 bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1;
473 bfd_signed_vma reloc_signed_min = ~reloc_signed_max;
474 if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
478 case complain_overflow_unsigned:
480 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;
488 if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) != (-1 & ~reloc_bits)))
496 relocation >>= (bfd_vma) howto->rightshift;
497 relocation <<= (bfd_vma) howto->bitpos;
498 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask));
506 bfd_put_16 (input_bfd, x, location);
509 bfd_putb_24 (input_bfd, x, location);
512 bfd_put_8 (input_bfd, x, location);
515 bfd_put_32 (input_bfd, x, location);
518 return overflow ? bfd_reloc_overflow : bfd_reloc_ok;
521 /* Finish up the reading of an a.out file header */
523 static const bfd_target *
524 tic30_aout_object_p (abfd)
527 struct external_exec exec_bytes; /* Raw exec header from file */
528 struct internal_exec exec; /* Cleaned-up exec header */
529 const bfd_target *target;
531 if (bfd_read ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
534 if (bfd_get_error () != bfd_error_system_call)
535 bfd_set_error (bfd_error_wrong_format);
540 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
542 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
543 #endif /* SWAP_MAGIC */
548 if (!(MACHTYPE_OK (N_MACHTYPE (exec))))
552 NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
555 /* swap_exec_header_in read in a_info with the wrong byte order */
556 exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
557 #endif /* SWAP_MAGIC */
559 target = NAME (aout, some_aout_object_p) (abfd, &exec, tic30_aout_callback);
561 #ifdef ENTRY_CAN_BE_ZERO
562 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
563 * means that it isn't obvious if EXEC_P should be set.
564 * All of the following must be true for an executable:
565 * There must be no relocations, the bfd can be neither an
566 * archive nor an archive element, and the file must be executable. */
568 if (exec.a_trsize + exec.a_drsize == 0
569 && bfd_get_format (abfd) == bfd_object && abfd->my_archive == NULL)
573 #define S_IXUSR 0100 /* Execute by owner. */
575 if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
576 abfd->flags |= EXEC_P;
578 #endif /* ENTRY_CAN_BE_ZERO */
583 /* Copy private section data. This actually does nothing with the
584 sections. It copies the subformat field. We copy it here, because
585 we need to know whether this is a QMAGIC file before we set the
586 section contents, and copy_private_bfd_data is not called until
587 after the section contents have been set. */
590 MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
592 asection *isec ATTRIBUTE_UNUSED;
594 asection *osec ATTRIBUTE_UNUSED;
596 if (bfd_get_flavour (obfd) == bfd_target_aout_flavour)
597 obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
601 /* Write an object file.
602 Section contents have already been written. We write the
603 file header, symbols, and relocation. */
606 tic30_aout_write_object_contents (abfd)
609 struct external_exec exec_bytes;
610 struct internal_exec *execp = exec_hdr (abfd);
612 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
615 bfd_size_type text_size; /* dummy vars */
617 if (adata (abfd).magic == undecided_magic)
618 NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end);
620 execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;
621 execp->a_entry = bfd_get_start_address (abfd);
623 execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
624 execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * obj_reloc_entry_size (abfd));
625 NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes);
627 if (adata (abfd).exec_bytes_size > 0)
629 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
631 if (bfd_write ((PTR) & exec_bytes, 1, adata (abfd).exec_bytes_size, abfd) != adata (abfd).exec_bytes_size)
634 /* Now write out reloc info, followed by syms and strings */
636 if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
637 && bfd_get_symcount (abfd) != 0)
639 if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0)
642 if (!NAME (aout, write_syms) (abfd))
646 if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)
648 if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
651 if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)
653 if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
661 tic30_aout_set_sizes (abfd)
664 adata (abfd).page_size = TARGET_PAGE_SIZE;
667 adata (abfd).segment_size = SEGMENT_SIZE;
669 adata (abfd).segment_size = TARGET_PAGE_SIZE;
672 #ifdef ZMAGIC_DISK_BLOCK_SIZE
673 adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
675 adata (abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
678 adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
683 #ifndef MY_final_link_callback
685 /* Callback for the final_link routine to set the section offsets. */
687 static void MY_final_link_callback
688 PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
691 MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff)
697 struct internal_exec *execp = exec_hdr (abfd);
699 *ptreloff = obj_datasec (abfd)->filepos + execp->a_data;
700 *pdreloff = *ptreloff + execp->a_trsize;
701 *psymoff = *pdreloff + execp->a_drsize;;
706 #ifndef MY_bfd_final_link
708 /* Final link routine. We need to use a call back to get the correct
709 offsets in the output file. */
712 MY_bfd_final_link (abfd, info)
714 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)->_raw_size;
732 vma += obj_textsec (abfd)->_raw_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);
744 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
746 if (obj_datasec (abfd)->vma < vma)
748 obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4);
750 obj_datasec (abfd)->user_set_vma = 1;
751 vma = obj_datasec (abfd)->vma;
752 obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size;
753 execp->a_text = vma - obj_textsec (abfd)->vma;
754 obj_textsec (abfd)->_raw_size = execp->a_text;
756 /* Since BSS follows data immediately, see if it needs alignment. */
757 vma += obj_datasec (abfd)->_raw_size;
758 pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma;
759 obj_datasec (abfd)->_raw_size += pad;
760 pos += obj_datasec (abfd)->_raw_size;
761 execp->a_data = obj_datasec (abfd)->_raw_size;
764 obj_bsssec (abfd)->vma = vma;
765 obj_bsssec (abfd)->user_set_vma = 1;
767 /* We are fully resized, so don't readjust in final_link. */
768 adata (abfd).magic = z_magic;
770 return NAME (aout, final_link) (abfd, info, MY_final_link_callback);
776 tic30_aout_machine_type (arch, machine, unknown)
777 enum bfd_architecture arch;
778 unsigned long machine ATTRIBUTE_UNUSED;
781 enum machine_type arch_flags;
783 arch_flags = M_UNKNOWN;
792 arch_flags = M_UNKNOWN;
794 if (arch_flags != M_UNKNOWN)
800 tic30_aout_set_arch_mach (abfd, arch, machine)
802 enum bfd_architecture arch;
803 unsigned long machine;
805 if (!bfd_default_set_arch_mach (abfd, arch, machine))
807 if (arch != bfd_arch_unknown)
810 tic30_aout_machine_type (arch, machine, &unknown);
814 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
815 return (*aout_backend_info (abfd)->set_sizes) (abfd);
818 /* We assume BFD generic archive files. */
819 #ifndef MY_openr_next_archived_file
820 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
822 #ifndef MY_get_elt_at_index
823 #define MY_get_elt_at_index _bfd_generic_get_elt_at_index
825 #ifndef MY_generic_stat_arch_elt
826 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
828 #ifndef MY_slurp_armap
829 #define MY_slurp_armap bfd_slurp_bsd_armap
831 #ifndef MY_slurp_extended_name_table
832 #define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
834 #ifndef MY_construct_extended_name_table
835 #define MY_construct_extended_name_table \
836 _bfd_archive_bsd_construct_extended_name_table
838 #ifndef MY_write_armap
839 #define MY_write_armap bsd_write_armap
841 #ifndef MY_read_ar_hdr
842 #define MY_read_ar_hdr _bfd_generic_read_ar_hdr
844 #ifndef MY_truncate_arname
845 #define MY_truncate_arname bfd_bsd_truncate_arname
847 #ifndef MY_update_armap_timestamp
848 #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
851 /* No core file defined here -- configure in trad-core.c separately. */
852 #ifndef MY_core_file_failing_command
853 #define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
855 #ifndef MY_core_file_failing_signal
856 #define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
858 #ifndef MY_core_file_matches_executable_p
859 #define MY_core_file_matches_executable_p \
860 _bfd_nocore_core_file_matches_executable_p
862 #ifndef MY_core_file_p
863 #define MY_core_file_p _bfd_dummy_target
866 #ifndef MY_bfd_debug_info_start
867 #define MY_bfd_debug_info_start bfd_void
869 #ifndef MY_bfd_debug_info_end
870 #define MY_bfd_debug_info_end bfd_void
872 #ifndef MY_bfd_debug_info_accumulate
873 #define MY_bfd_debug_info_accumulate \
874 (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
877 #ifndef MY_core_file_failing_command
878 #define MY_core_file_failing_command NAME(aout,core_file_failing_command)
880 #ifndef MY_core_file_failing_signal
881 #define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
883 #ifndef MY_core_file_matches_executable_p
884 #define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
886 #ifndef MY_set_section_contents
887 #define MY_set_section_contents NAME(aout,set_section_contents)
889 #ifndef MY_get_section_contents
890 #define MY_get_section_contents aout_32_get_section_contents
892 #ifndef MY_get_section_contents_in_window
893 #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
895 #ifndef MY_new_section_hook
896 #define MY_new_section_hook NAME(aout,new_section_hook)
898 #ifndef MY_get_symtab_upper_bound
899 #define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
901 #ifndef MY_get_symtab
902 #define MY_get_symtab NAME(aout,get_symtab)
904 #ifndef MY_get_reloc_upper_bound
905 #define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
907 #ifndef MY_canonicalize_reloc
908 #define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
910 #ifndef MY_make_empty_symbol
911 #define MY_make_empty_symbol NAME(aout,make_empty_symbol)
913 #ifndef MY_print_symbol
914 #define MY_print_symbol NAME(aout,print_symbol)
916 #ifndef MY_get_symbol_info
917 #define MY_get_symbol_info NAME(aout,get_symbol_info)
919 #ifndef MY_get_lineno
920 #define MY_get_lineno NAME(aout,get_lineno)
922 #ifndef MY_set_arch_mach
923 #define MY_set_arch_mach tic30_aout_set_arch_mach
925 #ifndef MY_find_nearest_line
926 #define MY_find_nearest_line NAME(aout,find_nearest_line)
928 #ifndef MY_sizeof_headers
929 #define MY_sizeof_headers NAME(aout,sizeof_headers)
931 #ifndef MY_bfd_get_relocated_section_contents
932 #define MY_bfd_get_relocated_section_contents \
933 bfd_generic_get_relocated_section_contents
935 #ifndef MY_bfd_relax_section
936 #define MY_bfd_relax_section bfd_generic_relax_section
938 #ifndef MY_bfd_gc_sections
939 #define MY_bfd_gc_sections bfd_generic_gc_sections
941 #ifndef MY_bfd_reloc_type_lookup
942 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
944 #ifndef MY_bfd_make_debug_symbol
945 #define MY_bfd_make_debug_symbol 0
947 #ifndef MY_read_minisymbols
948 #define MY_read_minisymbols NAME(aout,read_minisymbols)
950 #ifndef MY_minisymbol_to_symbol
951 #define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol)
953 #ifndef MY_bfd_link_hash_table_create
954 #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create)
956 #ifndef MY_bfd_link_add_symbols
957 #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols)
959 #ifndef MY_bfd_link_split_section
960 #define MY_bfd_link_split_section _bfd_generic_link_split_section
963 #ifndef MY_bfd_copy_private_bfd_data
964 #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
967 #ifndef MY_bfd_merge_private_bfd_data
968 #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
971 #ifndef MY_bfd_copy_private_symbol_data
972 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
975 #ifndef MY_bfd_print_private_bfd_data
976 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
979 #ifndef MY_bfd_set_private_flags
980 #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
983 #ifndef MY_bfd_is_local_label_name
984 #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
987 #ifndef MY_bfd_free_cached_info
988 #define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info)
991 #ifndef MY_close_and_cleanup
992 #define MY_close_and_cleanup MY_bfd_free_cached_info
995 #ifndef MY_get_dynamic_symtab_upper_bound
996 #define MY_get_dynamic_symtab_upper_bound \
997 _bfd_nodynamic_get_dynamic_symtab_upper_bound
999 #ifndef MY_canonicalize_dynamic_symtab
1000 #define MY_canonicalize_dynamic_symtab \
1001 _bfd_nodynamic_canonicalize_dynamic_symtab
1003 #ifndef MY_get_dynamic_reloc_upper_bound
1004 #define MY_get_dynamic_reloc_upper_bound \
1005 _bfd_nodynamic_get_dynamic_reloc_upper_bound
1007 #ifndef MY_canonicalize_dynamic_reloc
1008 #define MY_canonicalize_dynamic_reloc \
1009 _bfd_nodynamic_canonicalize_dynamic_reloc
1012 /* Aout symbols normally have leading underscores */
1013 #ifndef MY_symbol_leading_char
1014 #define MY_symbol_leading_char '_'
1017 /* Aout archives normally use spaces for padding */
1019 #define AR_PAD_CHAR ' '
1022 #ifndef MY_BFD_TARGET
1023 const bfd_target tic30_aout_vec =
1025 TARGETNAME, /* name */
1026 bfd_target_aout_flavour,
1027 BFD_ENDIAN_BIG, /* target byte order (big) */
1028 BFD_ENDIAN_BIG, /* target headers byte order (big) */
1029 (HAS_RELOC | /* object flags */
1030 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
1031 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
1032 MY_symbol_leading_char,
1033 AR_PAD_CHAR, /* ar_pad_char */
1034 15, /* ar_max_namelen */
1035 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1036 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1037 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
1038 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
1039 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
1040 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
1041 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
1042 bfd_generic_archive_p, MY_core_file_p},
1043 {bfd_false, MY_mkobject, /* bfd_set_format */
1044 _bfd_generic_mkarchive, bfd_false},
1045 {bfd_false, MY_write_object_contents, /* bfd_write_contents */
1046 _bfd_write_archive_contents, bfd_false},
1048 BFD_JUMP_TABLE_GENERIC (MY),
1049 BFD_JUMP_TABLE_COPY (MY),
1050 BFD_JUMP_TABLE_CORE (MY),
1051 BFD_JUMP_TABLE_ARCHIVE (MY),
1052 BFD_JUMP_TABLE_SYMBOLS (MY),
1053 BFD_JUMP_TABLE_RELOCS (MY),
1054 BFD_JUMP_TABLE_WRITE (MY),
1055 BFD_JUMP_TABLE_LINK (MY),
1056 BFD_JUMP_TABLE_DYNAMIC (MY),
1060 (PTR) MY_backend_data
1062 #endif /* MY_BFD_TARGET */