1 /* BFD back-end for TMS320C30 a.out binaries.
2 Copyright (C) 1998-2014 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA
22 #define TARGET_IS_BIG_ENDIAN_P
23 #define N_HEADER_IN_TEXT(x) 1
24 #define TEXT_START_ADDR 1024
25 #define TARGET_PAGE_SIZE 128
26 #define SEGMENT_SIZE TARGET_PAGE_SIZE
27 #define DEFAULT_ARCH bfd_arch_tic30
30 /* Do not "beautify" the CONCAT* macro args. Traditional C will not
31 remove whitespace added here, and thus will fail to concatenate
33 #define MY(OP) CONCAT2 (tic30_aout_,OP)
34 #define TARGETNAME "a.out-tic30"
35 #define NAME(x,y) CONCAT3 (tic30_aout,_32_,y)
40 #include "aout/aout64.h"
41 #include "aout/stab_gnu.h"
44 #define MY_reloc_howto(BFD, REL, IN, EX, PC) tic30_aout_reloc_howto (BFD, REL, & IN, & EX, & PC)
46 #define MY_final_link_relocate tic30_aout_final_link_relocate
47 #define MY_object_p tic30_aout_object_p
48 #define MY_mkobject NAME (aout,mkobject)
49 #define MY_write_object_contents tic30_aout_write_object_contents
50 #define MY_set_sizes tic30_aout_set_sizes
52 #ifndef MY_exec_hdr_flags
53 #define MY_exec_hdr_flags 1
56 #ifndef MY_backend_data
58 #ifndef MY_zmagic_contiguous
59 #define MY_zmagic_contiguous 0
61 #ifndef MY_text_includes_header
62 #define MY_text_includes_header 0
64 #ifndef MY_entry_is_text_address
65 #define MY_entry_is_text_address 0
67 #ifndef MY_exec_header_not_counted
68 #define MY_exec_header_not_counted 1
70 #ifndef MY_add_dynamic_symbols
71 #define MY_add_dynamic_symbols 0
73 #ifndef MY_add_one_symbol
74 #define MY_add_one_symbol 0
76 #ifndef MY_link_dynamic_object
77 #define MY_link_dynamic_object 0
79 #ifndef MY_write_dynamic_symbol
80 #define MY_write_dynamic_symbol 0
82 #ifndef MY_check_dynamic_reloc
83 #define MY_check_dynamic_reloc 0
85 #ifndef MY_finish_dynamic_link
86 #define MY_finish_dynamic_link 0
90 tic30_aout_set_sizes (bfd
*abfd
)
92 adata (abfd
).page_size
= TARGET_PAGE_SIZE
;
95 adata (abfd
).segment_size
= SEGMENT_SIZE
;
97 adata (abfd
).segment_size
= TARGET_PAGE_SIZE
;
100 #ifdef ZMAGIC_DISK_BLOCK_SIZE
101 adata (abfd
).zmagic_disk_block_size
= ZMAGIC_DISK_BLOCK_SIZE
;
103 adata (abfd
).zmagic_disk_block_size
= TARGET_PAGE_SIZE
;
106 adata (abfd
).exec_bytes_size
= EXEC_BYTES_SIZE
;
111 static const struct aout_backend_data tic30_aout_backend_data
=
113 MY_zmagic_contiguous
,
114 MY_text_includes_header
,
115 MY_entry_is_text_address
,
119 MY_exec_header_not_counted
,
120 MY_add_dynamic_symbols
,
122 MY_link_dynamic_object
,
123 MY_write_dynamic_symbol
,
124 MY_check_dynamic_reloc
,
125 MY_finish_dynamic_link
127 #define MY_backend_data &tic30_aout_backend_data
130 static reloc_howto_type
*
131 tic30_aout_reloc_howto (bfd
*, struct reloc_std_external
*, int *, int *, int *);
132 static bfd_reloc_status_type
133 tic30_aout_final_link_relocate
134 (reloc_howto_type
*, bfd
*, asection
*, bfd_byte
*, bfd_vma
, bfd_vma
, bfd_vma
);
136 /* FIXME: This is wrong. aoutx.h should really only be included by
141 /* This function is used to work out pc-relative offsets for the
142 TMS320C30. The data already placed by md_pcrel_from within gas is
143 useless for a relocation, so we just get the offset value and place
144 a version of this within the object code.
145 tic30_aout_final_link_relocate will then calculate the required
146 relocation to add on to the value in the object code. */
148 static bfd_reloc_status_type
149 tic30_aout_fix_pcrel_16 (bfd
*abfd
,
150 arelent
*reloc_entry
,
151 asymbol
*symbol ATTRIBUTE_UNUSED
,
153 asection
*input_section ATTRIBUTE_UNUSED
,
154 bfd
*output_bfd ATTRIBUTE_UNUSED
,
155 char **error_message ATTRIBUTE_UNUSED
)
157 bfd_vma relocation
= 1;
158 bfd_byte offset_data
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
- 1);
160 /* The byte before the location of the fix contains bits 23-16 of
161 the pcrel instruction. Bit 21 is set for a delayed instruction
162 which requires on offset of 3 instead of 1. */
163 if (offset_data
& 0x20)
167 bfd_put_16 (abfd
, relocation
, (bfd_byte
*) data
+ reloc_entry
->address
);
171 /* This function is used as a callback for 16-bit relocs. This is
172 required for relocations between segments. A line in aoutx.h
173 requires that any relocations for the data section should point to
174 the end of the aligned text section, plus an offset. By default,
175 this does not happen, therefore this function takes care of
178 static bfd_reloc_status_type
179 tic30_aout_fix_16 (bfd
*abfd
,
180 arelent
*reloc_entry
,
183 asection
*input_section ATTRIBUTE_UNUSED
,
185 char **error_message ATTRIBUTE_UNUSED
)
189 /* Make sure that the symbol's section is defined. */
190 if (bfd_is_und_section (symbol
->section
) && (symbol
->flags
& BSF_WEAK
) == 0)
191 return output_bfd
? bfd_reloc_ok
: bfd_reloc_undefined
;
192 /* Get the size of the input section and turn it into the TMS320C30
193 32-bit address format. */
194 relocation
= (symbol
->section
->vma
>> 2);
195 relocation
+= bfd_get_16 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
196 bfd_put_16 (abfd
, relocation
, (bfd_byte
*) data
+ reloc_entry
->address
);
200 /* This function does the same thing as tic30_aout_fix_16 except for 32
203 static bfd_reloc_status_type
204 tic30_aout_fix_32 (bfd
*abfd
,
205 arelent
*reloc_entry
,
208 asection
*input_section ATTRIBUTE_UNUSED
,
210 char **error_message ATTRIBUTE_UNUSED
)
214 /* Make sure that the symbol's section is defined. */
215 if (bfd_is_und_section (symbol
->section
) && (symbol
->flags
& BSF_WEAK
) == 0)
216 return output_bfd
? bfd_reloc_ok
: bfd_reloc_undefined
;
217 /* Get the size of the input section and turn it into the TMS320C30
218 32-bit address format. */
219 relocation
= (symbol
->section
->vma
>> 2);
220 relocation
+= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
221 bfd_put_32 (abfd
, relocation
, (bfd_byte
*) data
+ reloc_entry
->address
);
225 /* This table lists the relocation types for the TMS320C30. There are
226 only a few relocations required, and all must be divided by 4 (>>
227 2) to get the 32-bit addresses in the format the TMS320C30 likes
229 reloc_howto_type tic30_aout_howto_table
[] =
232 HOWTO (1, 2, 1, 16, FALSE
, 0, 0, tic30_aout_fix_16
,
233 "16", FALSE
, 0x0000FFFF, 0x0000FFFF, FALSE
),
234 HOWTO (2, 2, 2, 24, FALSE
, 0, complain_overflow_bitfield
, NULL
,
235 "24", FALSE
, 0x00FFFFFF, 0x00FFFFFF, FALSE
),
236 HOWTO (3, 18, 3, 24, FALSE
, 0, complain_overflow_bitfield
, NULL
,
237 "LDP", FALSE
, 0x00FF0000, 0x000000FF, FALSE
),
238 HOWTO (4, 2, 4, 32, FALSE
, 0, complain_overflow_bitfield
, tic30_aout_fix_32
,
239 "32", FALSE
, 0xFFFFFFFF, 0xFFFFFFFF, FALSE
),
240 HOWTO (5, 2, 1, 16, TRUE
, 0, complain_overflow_signed
,
241 tic30_aout_fix_pcrel_16
, "PCREL", TRUE
, 0x0000FFFF, 0x0000FFFF, TRUE
),
250 static reloc_howto_type
*
251 tic30_aout_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
252 bfd_reloc_code_real_type code
)
257 case BFD_RELOC_TIC30_LDP
:
258 return &tic30_aout_howto_table
[3];
260 return &tic30_aout_howto_table
[1];
262 return &tic30_aout_howto_table
[2];
263 case BFD_RELOC_16_PCREL
:
264 return &tic30_aout_howto_table
[5];
266 return &tic30_aout_howto_table
[4];
272 static reloc_howto_type
*
273 tic30_aout_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
279 i
< (sizeof (tic30_aout_howto_table
)
280 / sizeof (tic30_aout_howto_table
[0]));
282 if (tic30_aout_howto_table
[i
].name
!= NULL
283 && strcasecmp (tic30_aout_howto_table
[i
].name
, r_name
) == 0)
284 return &tic30_aout_howto_table
[i
];
289 static reloc_howto_type
*
290 tic30_aout_reloc_howto (bfd
*abfd
,
291 struct reloc_std_external
*relocs
,
296 unsigned int r_length
;
297 unsigned int r_pcrel_done
;
301 if (bfd_header_big_endian (abfd
))
303 *r_index
= ((relocs
->r_index
[0] << 16) | (relocs
->r_index
[1] << 8) | relocs
->r_index
[2]);
304 *r_extern
= (0 != (relocs
->r_type
[0] & RELOC_STD_BITS_EXTERN_BIG
));
305 r_pcrel_done
= (0 != (relocs
->r_type
[0] & RELOC_STD_BITS_PCREL_BIG
));
306 r_length
= ((relocs
->r_type
[0] & RELOC_STD_BITS_LENGTH_BIG
) >> RELOC_STD_BITS_LENGTH_SH_BIG
);
310 *r_index
= ((relocs
->r_index
[2] << 16) | (relocs
->r_index
[1] << 8) | relocs
->r_index
[0]);
311 *r_extern
= (0 != (relocs
->r_type
[0] & RELOC_STD_BITS_EXTERN_LITTLE
));
312 r_pcrel_done
= (0 != (relocs
->r_type
[0] & RELOC_STD_BITS_PCREL_LITTLE
));
313 r_length
= ((relocs
->r_type
[0] & RELOC_STD_BITS_LENGTH_LITTLE
) >> RELOC_STD_BITS_LENGTH_SH_LITTLE
);
315 howto_index
= r_length
+ 4 * r_pcrel_done
;
316 return tic30_aout_howto_table
+ howto_index
;
319 /* These macros will get 24-bit values from the bfd definition.
321 #define bfd_getb_24(BFD,ADDR) \
322 (bfd_get_8 (BFD, ADDR ) << 16) | \
323 (bfd_get_8 (BFD, ADDR + 1) << 8) | \
324 (bfd_get_8 (BFD, ADDR + 2) )
326 #define bfd_putb_24(BFD,DATA,ADDR) \
327 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 16) & 0xFF), ADDR ); \
328 bfd_put_8 (BFD, (bfd_byte) ((DATA >> 8) & 0xFF), ADDR + 1); \
329 bfd_put_8 (BFD, (bfd_byte) ( DATA & 0xFF), ADDR + 2)
331 /* Set parameters about this a.out file that are machine-dependent.
332 This routine is called from some_aout_object_p just before it returns. */
334 static const bfd_target
*
335 tic30_aout_callback (bfd
*abfd
)
337 struct internal_exec
*execp
= exec_hdr (abfd
);
338 unsigned int arch_align_power
;
339 unsigned long arch_align
;
341 /* Calculate the file positions of the parts of a newly read aout header. */
342 obj_textsec (abfd
)->size
= N_TXTSIZE (*execp
);
344 /* The virtual memory addresses of the sections. */
345 obj_textsec (abfd
)->vma
= N_TXTADDR (*execp
);
346 obj_datasec (abfd
)->vma
= N_DATADDR (*execp
);
347 obj_bsssec (abfd
)->vma
= N_BSSADDR (*execp
);
349 obj_textsec (abfd
)->lma
= obj_textsec (abfd
)->vma
;
350 obj_datasec (abfd
)->lma
= obj_datasec (abfd
)->vma
;
351 obj_bsssec (abfd
)->lma
= obj_bsssec (abfd
)->vma
;
353 /* The file offsets of the sections. */
354 obj_textsec (abfd
)->filepos
= N_TXTOFF (*execp
);
355 obj_datasec (abfd
)->filepos
= N_DATOFF (*execp
);
357 /* The file offsets of the relocation info. */
358 obj_textsec (abfd
)->rel_filepos
= N_TRELOFF (*execp
);
359 obj_datasec (abfd
)->rel_filepos
= N_DRELOFF (*execp
);
361 /* The file offsets of the string table and symbol table. */
362 obj_sym_filepos (abfd
) = N_SYMOFF (*execp
);
363 obj_str_filepos (abfd
) = N_STROFF (*execp
);
365 /* Determine the architecture and machine type of the object file. */
367 SET_ARCH_MACH (abfd
, *execp
);
369 bfd_default_set_arch_mach (abfd
, DEFAULT_ARCH
, 0L);
372 /* Now that we know the architecture, set the alignments of the
373 sections. This is normally done by NAME (aout,new_section_hook),
374 but when the initial sections were created the architecture had
375 not yet been set. However, for backward compatibility, we don't
376 set the alignment power any higher than as required by the size
378 arch_align_power
= bfd_get_arch_info (abfd
)->section_align_power
;
379 arch_align
= 1 << arch_align_power
;
380 if ((BFD_ALIGN (obj_textsec (abfd
)->size
, arch_align
)
381 == obj_textsec (abfd
)->size
)
382 && (BFD_ALIGN (obj_datasec (abfd
)->size
, arch_align
)
383 == obj_datasec (abfd
)->size
)
384 && (BFD_ALIGN (obj_bsssec (abfd
)->size
, arch_align
)
385 == obj_bsssec (abfd
)->size
))
387 obj_textsec (abfd
)->alignment_power
= arch_align_power
;
388 obj_datasec (abfd
)->alignment_power
= arch_align_power
;
389 obj_bsssec (abfd
)->alignment_power
= arch_align_power
;
394 static bfd_reloc_status_type
395 tic30_aout_relocate_contents (reloc_howto_type
*howto
,
401 bfd_boolean overflow
;
404 relocation
= -relocation
;
413 x
= bfd_get_16 (input_bfd
, location
);
416 x
= bfd_getb_24 (input_bfd
, location
);
419 x
= bfd_get_8 (input_bfd
, location
);
422 x
= bfd_get_32 (input_bfd
, location
);
428 if (howto
->complain_on_overflow
!= complain_overflow_dont
)
431 bfd_signed_vma signed_check
;
433 bfd_signed_vma signed_add
;
435 if (howto
->rightshift
== 0)
438 signed_check
= (bfd_signed_vma
) relocation
;
442 check
= relocation
>> howto
->rightshift
;
443 if ((bfd_signed_vma
) relocation
>= 0)
444 signed_check
= check
;
446 signed_check
= (check
| ((bfd_vma
) - 1 & ~((bfd_vma
) - 1 >> howto
->rightshift
)));
448 add
= x
& howto
->src_mask
;
450 if ((add
& (((~howto
->src_mask
) >> 1) & howto
->src_mask
)) != 0)
451 signed_add
-= (((~howto
->src_mask
) >> 1) & howto
->src_mask
) << 1;
452 if (howto
->bitpos
== 0)
455 signed_check
+= signed_add
;
459 check
+= add
>> howto
->bitpos
;
461 signed_check
+= add
>> howto
->bitpos
;
463 signed_check
+= ((add
>> howto
->bitpos
) | ((bfd_vma
) - 1 & ~((bfd_vma
) - 1 >> howto
->bitpos
)));
465 switch (howto
->complain_on_overflow
)
467 case complain_overflow_signed
:
469 bfd_signed_vma reloc_signed_max
= (1 << (howto
->bitsize
- 1)) - 1;
470 bfd_signed_vma reloc_signed_min
= ~reloc_signed_max
;
472 if (signed_check
> reloc_signed_max
|| signed_check
< reloc_signed_min
)
476 case complain_overflow_unsigned
:
478 bfd_vma reloc_unsigned_max
= (((1 << (howto
->bitsize
- 1)) - 1) << 1) | 1;
480 if (check
> reloc_unsigned_max
)
484 case complain_overflow_bitfield
:
486 bfd_vma reloc_bits
= (((1 << (howto
->bitsize
- 1)) - 1) << 1) | 1;
488 if ((check
& ~reloc_bits
) != 0
489 && (((bfd_vma
) signed_check
& ~reloc_bits
)
490 != ((bfd_vma
) -1 & ~reloc_bits
)))
498 relocation
>>= (bfd_vma
) howto
->rightshift
;
499 relocation
<<= (bfd_vma
) howto
->bitpos
;
500 x
= ((x
& ~howto
->dst_mask
) | (((x
& howto
->src_mask
) + relocation
) & howto
->dst_mask
));
508 bfd_put_16 (input_bfd
, x
, location
);
511 bfd_putb_24 (input_bfd
, x
, location
);
514 bfd_put_8 (input_bfd
, x
, location
);
517 bfd_put_32 (input_bfd
, x
, location
);
520 return overflow
? bfd_reloc_overflow
: bfd_reloc_ok
;
523 static bfd_reloc_status_type
524 tic30_aout_final_link_relocate (reloc_howto_type
*howto
,
526 asection
*input_section
,
534 if (address
> bfd_get_section_limit (input_bfd
, input_section
))
535 return bfd_reloc_outofrange
;
537 relocation
= value
+ addend
;
538 if (howto
->pc_relative
)
540 relocation
-= (input_section
->output_section
->vma
+ input_section
->output_offset
);
541 if (howto
->pcrel_offset
)
542 relocation
-= address
;
544 return tic30_aout_relocate_contents (howto
, input_bfd
, relocation
,
548 /* Finish up the reading of an a.out file header. */
550 static const bfd_target
*
551 tic30_aout_object_p (bfd
*abfd
)
553 struct external_exec exec_bytes
; /* Raw exec header from file. */
554 struct internal_exec exec
; /* Cleaned-up exec header. */
555 const bfd_target
*target
;
556 bfd_size_type amt
= EXEC_BYTES_SIZE
;
558 if (bfd_bread (& exec_bytes
, amt
, abfd
) != amt
)
560 if (bfd_get_error () != bfd_error_system_call
)
561 bfd_set_error (bfd_error_wrong_format
);
566 exec
.a_info
= SWAP_MAGIC (exec_bytes
.e_info
);
568 exec
.a_info
= H_GET_32 (abfd
, exec_bytes
.e_info
);
569 #endif /* SWAP_MAGIC */
574 if (!(MACHTYPE_OK (N_MACHTYPE (exec
))))
578 NAME (aout
, swap_exec_header_in
) (abfd
, &exec_bytes
, &exec
);
581 /* Swap_exec_header_in read in a_info with the wrong byte order. */
582 exec
.a_info
= SWAP_MAGIC (exec_bytes
.e_info
);
585 target
= NAME (aout
, some_aout_object_p
) (abfd
, &exec
, tic30_aout_callback
);
587 #ifdef ENTRY_CAN_BE_ZERO
588 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
589 means that it isn't obvious if EXEC_P should be set.
590 All of the following must be true for an executable:
591 There must be no relocations, the bfd can be neither an
592 archive nor an archive element, and the file must be executable. */
594 if (exec
.a_trsize
+ exec
.a_drsize
== 0
595 && bfd_get_format (abfd
) == bfd_object
&& abfd
->my_archive
== NULL
)
599 #define S_IXUSR 0100 /* Execute by owner. */
601 if (stat (abfd
->filename
, &buf
) == 0 && (buf
.st_mode
& S_IXUSR
))
602 abfd
->flags
|= EXEC_P
;
609 /* Copy private section data. This actually does nothing with the
610 sections. It copies the subformat field. We copy it here, because
611 we need to know whether this is a QMAGIC file before we set the
612 section contents, and copy_private_bfd_data is not called until
613 after the section contents have been set. */
616 MY_bfd_copy_private_section_data (bfd
*ibfd
,
617 asection
*isec ATTRIBUTE_UNUSED
,
619 asection
*osec ATTRIBUTE_UNUSED
)
621 if (bfd_get_flavour (obfd
) == bfd_target_aout_flavour
)
622 obj_aout_subformat (obfd
) = obj_aout_subformat (ibfd
);
626 /* Write an object file.
627 Section contents have already been written. We write the
628 file header, symbols, and relocation. */
631 tic30_aout_write_object_contents (bfd
*abfd
)
633 struct external_exec exec_bytes
;
634 struct internal_exec
*execp
= exec_hdr (abfd
);
636 obj_reloc_entry_size (abfd
) = RELOC_STD_SIZE
;
639 bfd_size_type text_size
; /* Dummy vars. */
642 if (adata (abfd
).magic
== undecided_magic
)
643 NAME (aout
, adjust_sizes_and_vmas
) (abfd
, &text_size
, &text_end
);
645 execp
->a_syms
= bfd_get_symcount (abfd
) * EXTERNAL_NLIST_SIZE
;
646 execp
->a_entry
= bfd_get_start_address (abfd
);
648 execp
->a_trsize
= ((obj_textsec (abfd
)->reloc_count
) * obj_reloc_entry_size (abfd
));
649 execp
->a_drsize
= ((obj_datasec (abfd
)->reloc_count
) * obj_reloc_entry_size (abfd
));
650 NAME (aout
, swap_exec_header_out
) (abfd
, execp
, &exec_bytes
);
652 if (adata (abfd
).exec_bytes_size
> 0)
656 if (bfd_seek (abfd
, (file_ptr
) 0, SEEK_SET
) != 0)
658 amt
= adata (abfd
).exec_bytes_size
;
659 if (bfd_bwrite (& exec_bytes
, amt
, abfd
) != amt
)
663 /* Now write out reloc info, followed by syms and strings. */
664 if (bfd_get_outsymbols (abfd
) != (asymbol
**) NULL
665 && bfd_get_symcount (abfd
) != 0)
667 if (bfd_seek (abfd
, (file_ptr
) (N_SYMOFF (*execp
)), SEEK_SET
) != 0)
670 if (!NAME (aout
, write_syms
) (abfd
))
674 if (bfd_seek (abfd
, (file_ptr
) (N_TRELOFF (*execp
)), SEEK_SET
) != 0)
676 if (!NAME (aout
, squirt_out_relocs
) (abfd
, obj_textsec (abfd
)))
679 if (bfd_seek (abfd
, (file_ptr
) (N_DRELOFF (*execp
)), SEEK_SET
) != 0)
681 if (!NAME (aout
, squirt_out_relocs
) (abfd
, obj_datasec (abfd
)))
688 #ifndef MY_final_link_callback
690 /* Callback for the final_link routine to set the section offsets. */
693 MY_final_link_callback (bfd
*abfd
,
698 struct internal_exec
*execp
= exec_hdr (abfd
);
700 *ptreloff
= obj_datasec (abfd
)->filepos
+ execp
->a_data
;
701 *pdreloff
= *ptreloff
+ execp
->a_trsize
;
702 *psymoff
= *pdreloff
+ execp
->a_drsize
;
707 #ifndef MY_bfd_final_link
709 /* Final link routine. We need to use a call back to get the correct
710 offsets in the output file. */
713 MY_bfd_final_link (bfd
*abfd
, struct bfd_link_info
*info
)
715 struct internal_exec
*execp
= exec_hdr (abfd
);
720 /* Set the executable header size to 0, as we don't want one for an
722 adata (abfd
).exec_bytes_size
= 0;
723 pos
= adata (abfd
).exec_bytes_size
;
725 vma
= info
->create_object_symbols_section
->vma
;
727 obj_textsec (abfd
)->filepos
= pos
;
728 obj_textsec (abfd
)->vma
= vma
;
729 obj_textsec (abfd
)->user_set_vma
= 1;
730 pos
+= obj_textsec (abfd
)->size
;
731 vma
+= obj_textsec (abfd
)->size
;
734 if (abfd
->flags
& D_PAGED
)
736 if (info
->create_object_symbols_section
->next
->vma
> 0)
737 obj_datasec (abfd
)->vma
= info
->create_object_symbols_section
->next
->vma
;
739 obj_datasec (abfd
)->vma
= BFD_ALIGN (vma
, adata (abfd
).segment_size
);
742 obj_datasec (abfd
)->vma
= BFD_ALIGN (vma
, 4);
744 if (obj_datasec (abfd
)->vma
< vma
)
745 obj_datasec (abfd
)->vma
= BFD_ALIGN (vma
, 4);
747 obj_datasec (abfd
)->user_set_vma
= 1;
748 vma
= obj_datasec (abfd
)->vma
;
749 obj_datasec (abfd
)->filepos
= vma
+ adata (abfd
).exec_bytes_size
;
750 execp
->a_text
= vma
- obj_textsec (abfd
)->vma
;
751 obj_textsec (abfd
)->size
= execp
->a_text
;
753 /* Since BSS follows data immediately, see if it needs alignment. */
754 vma
+= obj_datasec (abfd
)->size
;
755 pad
= align_power (vma
, obj_bsssec (abfd
)->alignment_power
) - vma
;
756 obj_datasec (abfd
)->size
+= pad
;
757 pos
+= obj_datasec (abfd
)->size
;
758 execp
->a_data
= obj_datasec (abfd
)->size
;
761 obj_bsssec (abfd
)->vma
= vma
;
762 obj_bsssec (abfd
)->user_set_vma
= 1;
764 /* We are fully resized, so don't readjust in final_link. */
765 adata (abfd
).magic
= z_magic
;
767 return NAME (aout
, final_link
) (abfd
, info
, MY_final_link_callback
);
772 static enum machine_type
773 tic30_aout_machine_type (enum bfd_architecture arch
,
774 unsigned long machine ATTRIBUTE_UNUSED
,
775 bfd_boolean
*unknown
)
777 enum machine_type arch_flags
;
779 arch_flags
= M_UNKNOWN
;
788 arch_flags
= M_UNKNOWN
;
790 if (arch_flags
!= M_UNKNOWN
)
796 tic30_aout_set_arch_mach (bfd
*abfd
,
797 enum bfd_architecture arch
,
798 unsigned long machine
)
800 if (!bfd_default_set_arch_mach (abfd
, arch
, machine
))
802 if (arch
!= bfd_arch_unknown
)
805 tic30_aout_machine_type (arch
, machine
, &unknown
);
809 obj_reloc_entry_size (abfd
) = RELOC_STD_SIZE
;
810 return (*aout_backend_info (abfd
)->set_sizes
) (abfd
);
813 /* We assume BFD generic archive files. */
814 #ifndef MY_openr_next_archived_file
815 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
817 #ifndef MY_get_elt_at_index
818 #define MY_get_elt_at_index _bfd_generic_get_elt_at_index
820 #ifndef MY_generic_stat_arch_elt
821 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
823 #ifndef MY_slurp_armap
824 #define MY_slurp_armap bfd_slurp_bsd_armap
826 #ifndef MY_slurp_extended_name_table
827 #define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
829 #ifndef MY_construct_extended_name_table
830 #define MY_construct_extended_name_table \
831 _bfd_archive_bsd_construct_extended_name_table
833 #ifndef MY_write_armap
834 #define MY_write_armap bsd_write_armap
836 #ifndef MY_read_ar_hdr
837 #define MY_read_ar_hdr _bfd_generic_read_ar_hdr
839 #ifndef MY_write_ar_hdr
840 #define MY_write_ar_hdr _bfd_generic_write_ar_hdr
842 #ifndef MY_truncate_arname
843 #define MY_truncate_arname bfd_bsd_truncate_arname
845 #ifndef MY_update_armap_timestamp
846 #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
849 /* No core file defined here -- configure in trad-core.c separately. */
850 #ifndef MY_core_file_failing_command
851 #define MY_core_file_failing_command _bfd_nocore_core_file_failing_command
853 #ifndef MY_core_file_failing_signal
854 #define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal
856 #ifndef MY_core_file_matches_executable_p
857 #define MY_core_file_matches_executable_p \
858 _bfd_nocore_core_file_matches_executable_p
860 #ifndef MY_core_file_pid
861 #define MY_core_file_pid _bfd_nocore_core_file_pid
863 #ifndef MY_core_file_p
864 #define MY_core_file_p _bfd_dummy_target
867 #ifndef MY_bfd_debug_info_start
868 #define MY_bfd_debug_info_start bfd_void
870 #ifndef MY_bfd_debug_info_end
871 #define MY_bfd_debug_info_end bfd_void
873 #ifndef MY_bfd_debug_info_accumulate
874 #define MY_bfd_debug_info_accumulate \
875 (void (*) (bfd*, struct bfd_section *)) bfd_void
878 #ifndef MY_core_file_failing_command
879 #define MY_core_file_failing_command NAME (aout, core_file_failing_command)
881 #ifndef MY_core_file_failing_signal
882 #define MY_core_file_failing_signal NAME (aout, core_file_failing_signal)
884 #ifndef MY_core_file_matches_executable_p
885 #define MY_core_file_matches_executable_p NAME (aout, core_file_matches_executable_p)
887 #ifndef MY_set_section_contents
888 #define MY_set_section_contents NAME (aout, set_section_contents)
890 #ifndef MY_get_section_contents
891 #define MY_get_section_contents aout_32_get_section_contents
893 #ifndef MY_get_section_contents_in_window
894 #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
896 #ifndef MY_new_section_hook
897 #define MY_new_section_hook NAME (aout, new_section_hook)
899 #ifndef MY_get_symtab_upper_bound
900 #define MY_get_symtab_upper_bound NAME (aout, get_symtab_upper_bound)
902 #ifndef MY_canonicalize_symtab
903 #define MY_canonicalize_symtab NAME (aout, canonicalize_symtab)
905 #ifndef MY_get_reloc_upper_bound
906 #define MY_get_reloc_upper_bound NAME (aout, get_reloc_upper_bound)
908 #ifndef MY_canonicalize_reloc
909 #define MY_canonicalize_reloc NAME (aout, canonicalize_reloc)
911 #ifndef MY_make_empty_symbol
912 #define MY_make_empty_symbol NAME (aout, make_empty_symbol)
914 #ifndef MY_print_symbol
915 #define MY_print_symbol NAME (aout, print_symbol)
917 #ifndef MY_get_symbol_info
918 #define MY_get_symbol_info NAME (aout, get_symbol_info)
920 #ifndef MY_get_lineno
921 #define MY_get_lineno NAME (aout, get_lineno)
923 #ifndef MY_set_arch_mach
924 #define MY_set_arch_mach tic30_aout_set_arch_mach
926 #ifndef MY_find_nearest_line
927 #define MY_find_nearest_line NAME (aout, find_nearest_line)
930 #define MY_find_line _bfd_nosymbols_find_line
932 #ifndef MY_find_inliner_info
933 #define MY_find_inliner_info _bfd_nosymbols_find_inliner_info
935 #ifndef MY_sizeof_headers
936 #define MY_sizeof_headers NAME (aout, sizeof_headers)
938 #ifndef MY_bfd_get_relocated_section_contents
939 #define MY_bfd_get_relocated_section_contents \
940 bfd_generic_get_relocated_section_contents
942 #ifndef MY_bfd_relax_section
943 #define MY_bfd_relax_section bfd_generic_relax_section
945 #ifndef MY_bfd_gc_sections
946 #define MY_bfd_gc_sections bfd_generic_gc_sections
948 #ifndef MY_bfd_lookup_section_flags
949 #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags
951 #ifndef MY_bfd_merge_sections
952 #define MY_bfd_merge_sections bfd_generic_merge_sections
954 #ifndef MY_bfd_is_group_section
955 #define MY_bfd_is_group_section bfd_generic_is_group_section
957 #ifndef MY_bfd_discard_group
958 #define MY_bfd_discard_group bfd_generic_discard_group
960 #ifndef MY_section_already_linked
961 #define MY_section_already_linked \
962 _bfd_generic_section_already_linked
964 #ifndef MY_bfd_define_common_symbol
965 #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
967 #ifndef MY_bfd_reloc_type_lookup
968 #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup
970 #ifndef MY_bfd_reloc_name_lookup
971 #define MY_bfd_reloc_name_lookup tic30_aout_reloc_name_lookup
973 #ifndef MY_bfd_make_debug_symbol
974 #define MY_bfd_make_debug_symbol 0
976 #ifndef MY_read_minisymbols
977 #define MY_read_minisymbols NAME (aout, read_minisymbols)
979 #ifndef MY_minisymbol_to_symbol
980 #define MY_minisymbol_to_symbol NAME (aout, minisymbol_to_symbol)
982 #ifndef MY_bfd_link_hash_table_create
983 #define MY_bfd_link_hash_table_create NAME (aout, link_hash_table_create)
985 #ifndef MY_bfd_link_add_symbols
986 #define MY_bfd_link_add_symbols NAME (aout, link_add_symbols)
988 #ifndef MY_bfd_link_just_syms
989 #define MY_bfd_link_just_syms _bfd_generic_link_just_syms
991 #ifndef MY_bfd_copy_link_hash_symbol_type
992 #define MY_bfd_copy_link_hash_symbol_type \
993 _bfd_generic_copy_link_hash_symbol_type
995 #ifndef MY_bfd_link_split_section
996 #define MY_bfd_link_split_section _bfd_generic_link_split_section
999 #ifndef MY_bfd_copy_private_bfd_data
1000 #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
1003 #ifndef MY_bfd_merge_private_bfd_data
1004 #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
1007 #ifndef MY_bfd_copy_private_symbol_data
1008 #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
1011 #ifndef MY_bfd_copy_private_header_data
1012 #define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
1015 #ifndef MY_bfd_print_private_bfd_data
1016 #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
1019 #ifndef MY_bfd_set_private_flags
1020 #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
1023 #ifndef MY_bfd_is_local_label_name
1024 #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
1027 #ifndef MY_bfd_is_target_special_symbol
1028 #define MY_bfd_is_target_special_symbol \
1029 ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
1032 #ifndef MY_bfd_free_cached_info
1033 #define MY_bfd_free_cached_info NAME (aout, bfd_free_cached_info)
1036 #ifndef MY_close_and_cleanup
1037 #define MY_close_and_cleanup MY_bfd_free_cached_info
1040 #ifndef MY_get_dynamic_symtab_upper_bound
1041 #define MY_get_dynamic_symtab_upper_bound \
1042 _bfd_nodynamic_get_dynamic_symtab_upper_bound
1044 #ifndef MY_canonicalize_dynamic_symtab
1045 #define MY_canonicalize_dynamic_symtab \
1046 _bfd_nodynamic_canonicalize_dynamic_symtab
1048 #ifndef MY_get_synthetic_symtab
1049 #define MY_get_synthetic_symtab \
1050 _bfd_nodynamic_get_synthetic_symtab
1052 #ifndef MY_get_dynamic_reloc_upper_bound
1053 #define MY_get_dynamic_reloc_upper_bound \
1054 _bfd_nodynamic_get_dynamic_reloc_upper_bound
1056 #ifndef MY_canonicalize_dynamic_reloc
1057 #define MY_canonicalize_dynamic_reloc \
1058 _bfd_nodynamic_canonicalize_dynamic_reloc
1061 /* Aout symbols normally have leading underscores. */
1062 #ifndef MY_symbol_leading_char
1063 #define MY_symbol_leading_char '_'
1066 /* Aout archives normally use spaces for padding. */
1068 #define AR_PAD_CHAR ' '
1071 #ifndef MY_BFD_TARGET
1072 const bfd_target tic30_aout_vec
=
1074 TARGETNAME
, /* Name. */
1075 bfd_target_aout_flavour
,
1076 BFD_ENDIAN_BIG
, /* Target byte order (big). */
1077 BFD_ENDIAN_BIG
, /* Target headers byte order (big). */
1078 (HAS_RELOC
| /* Object flags. */
1079 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
1080 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* Section flags. */
1081 MY_symbol_leading_char
,
1082 AR_PAD_CHAR
, /* AR_pad_char. */
1083 15, /* AR_max_namelen. */
1084 0, /* match priority. */
1085 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1086 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1087 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Data. */
1088 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
1089 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
1090 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Headers. */
1091 {_bfd_dummy_target
, MY_object_p
, /* bfd_check_format. */
1092 bfd_generic_archive_p
, MY_core_file_p
},
1093 {bfd_false
, MY_mkobject
, /* bfd_set_format. */
1094 _bfd_generic_mkarchive
, bfd_false
},
1095 {bfd_false
, MY_write_object_contents
, /* bfd_write_contents. */
1096 _bfd_write_archive_contents
, bfd_false
},
1098 BFD_JUMP_TABLE_GENERIC (MY
),
1099 BFD_JUMP_TABLE_COPY (MY
),
1100 BFD_JUMP_TABLE_CORE (MY
),
1101 BFD_JUMP_TABLE_ARCHIVE (MY
),
1102 BFD_JUMP_TABLE_SYMBOLS (MY
),
1103 BFD_JUMP_TABLE_RELOCS (MY
),
1104 BFD_JUMP_TABLE_WRITE (MY
),
1105 BFD_JUMP_TABLE_LINK (MY
),
1106 BFD_JUMP_TABLE_DYNAMIC (MY
),
1112 #endif /* MY_BFD_TARGET */